akhauriyash/Code-Regression huggingface dataset:
#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 rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ');
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

int t[110][110];

int main () {
  int w, h, n;
  cin >> w >> h >> n;
  rep(i,n) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      for (int j = 0; j < h; ++j) {
        for (int k = 0; k < x; ++k) {
          t[j][k] = 1;
        }
      }
    }
    if (a == 2) {
      for (int j = 0; j < h; ++j) {
        for (int k = x; k < w; ++k) {
          t[j][k] = 1;
        }
      }
    }
    if (a == 3) {
      for (int j = 0; j < y; ++j) {
        for (int k = 0; k < w; ++k) {
          t[j][k] = 1;
        }
      }
    }
    if (a == 4) {
      for (int j = y; j < h; ++j) {
        for (int k = 0; k < w; ++k) {
          t[j][k] = 1;
        }
      }
    }
  }

  int ans = 0;
  rep(i,h) {
    rep(j,w) {
      if (t[i][j] == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	ll n;
	cin>>n;
	ll pos = 1;
	ll a;
	ll count = 0;
	for(ll i=0;i<n;i++)
	{
		cin>>a;
		if(a==pos)
		{
			pos++;
		}
		else
		count ++;
	}
	if(pos==1)
	{
		cout<<-1;
	}
	else
	{
		cout<<count;
	}
}

Measured memory_bytes: 256
a = input().split()
a = [int(j) for j in a]
a.append(a[:2])
a.append(a[2:4])
if sum(a[4]) > sum(a[5]):
    print("Left")
if sum(a[4]) == sum(a[5]):
    print("Balanced")
if sum(a[4]) < sum(a[5]):
    print("Right")

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

ll GCD (ll x, ll y) {
  if (y == 0) return x;
  return GCD(y, x%y);
}
ll LCM (ll x, ll y) {
    return x / GCD(x,y) * y;
    // x*yはオーバーフローする可能性がある
}

int main() {
    int n;
    cin >> n;
    ll lcm = 1;
    rep(i,n) {
        ll t;
        cin >> t;
        lcm = LCM(lcm,t);
    }
    cout << lcm << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	if(s.size() == 26){
		string t = s;
		if(next_permutation(t.begin(), t.end())){
			for(int i = 0; i < 26; i++){
				if(s[i] == t[i]){
					cout<<t[i];
				}else{
					cout<<t[i];
					break;
				}
			}
		}else{
			cout<<-1<<endl;
		}
	}else{
		set<char> st;
		for(auto ch : s){
			st.insert(ch);
		}
		cout<<s;
		for(char x = 'a'; x <= 'z'; x++){
			if(!st.count(x)){
				cout<<x;
				break;
			}
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[100010];
ll n;
int main(){
	scanf("%s",s);
	n=strlen(s);
	for(ll i=n-1;i>=0;){
		if(i>=4&&!strcmp(s+i-4,"dream"))i-=5,s[i+1]=0;
		else if(i>=6&&!strcmp(s+i-6,"dreamer"))i-=7,s[i+1]=0;
		else if(i>=4&&!strcmp(s+i-4,"erase"))i-=5,s[i+1]=0;
		else if(i>=5&&!strcmp(s+i-5,"eraser"))i-=6,s[i+1]=0;
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 256
def main():
    import collections
    import heapq

    class Dijkstra:
        def __init__(self):
            self.e = collections.defaultdict(list)

        def add(self, u, v, d):  # 無向グラフの場合
            self.e[u].append([v, d])
            self.e[v].append([u, d])

        def delete(self, u, v):
            self.e[u] = [_ for _ in self.e[u] if _[0] != v]
            self.e[v] = [_ for _ in self.e[v] if _[0] != u]

        def search(self, s):  # d[i]はsからiまでの最短距離
            d = collections.defaultdict(lambda: float('inf'))
            d[s] = 0
            q = []
            heapq.heappush(q, (0, s))
            v = collections.defaultdict(bool)
            while len(q):
                k, u = heapq.heappop(q)
                if v[u]:
                    continue
                v[u] = True

                for uv, ud in self.e[u]:
                    if v[uv]:
                        continue
                    vd = k + ud
                    if d[uv] > vd:
                        d[uv] = vd
                        heapq.heappush(q, (vd, uv))

            return d

    n, m, s, t = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(m)]

    G1 = Dijkstra()
    G2 = Dijkstra()

    for i in range(m):
        G1.add(data[i][0], data[i][1], data[i][2])
        G2.add(data[i][0], data[i][1], data[i][3])

    D1 = G1.search(s)
    D2 = G2.search(t)

    A = []

    for i in range(1, n + 1):
        A.append((D1[i] + D2[i], i))

    A.sort()

    b = 0
    for i in range(n):
        if i == 0:
            print(10 ** 15 - A[i][0])
        elif i < A[b][1]:
            print(10 ** 15 - A[b][0])
        else:
            while i >= A[b][1]:
                b += 1
            print(10 ** 15 - A[b][0])

if __name__ == '__main__':
    main()

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

int gcd(int a, int b)
{
  if (a == 0) return b;
  while (b != 0) {
    int w = b;
    b = a % b;
    a = w;
  }
  return a;
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n), gcdl(n), gcdr(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  gcdl.at(0) = 0;
  for (int i = 0; i < n - 1; i++) {
    gcdl.at(i+1) = gcd(gcdl.at(i), a.at(i));
  }
  gcdr.at(0) = 0;
  for (int i = 0; i < n - 1; i++) {
    gcdr.at(i+1) = gcd(gcdr.at(i), a.at(n - 1 - i));
  }
  int max_gcd_vector = 0;
  for (int i = 0; i < n; i++) {
    int gcd_vector = gcd(gcdl.at(i), gcdr.at(n - 1 - i));
    if (max_gcd_vector < gcd_vector) max_gcd_vector = gcd_vector;
  }
  printf("%d\n", max_gcd_vector);
  return 0;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        long n=Long.parseLong(br.readLine());
        ArrayList<Integer> a=new ArrayList<>();
        for(long i=2;i*i<=n;i++){
            int count=0;
            while(n%i==0){
                count++;
                n/=i;
//                System.out.println(i);
            }
            if(count!=0){
                a.add(count);
            }
        }
        if(n!=1){
            a.add(1);
        }
//        System.out.println(a.toString());
        int ans=0;
        for(int k:a){
            int count=0;
            int temp=0;
            for(int i=1;i<=k;i++){
                temp+=i;
                if(temp>k){
                    break;
                }
                count++;
            }
            ans+=count;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25868
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
bool used[1005][1005];
struct BIT{
private:
  ll n;
  vector<ll> bit_array;
public:
  BIT(ll s){
    bit_array.resize(s+1,0);
    n=s;
  }
  void add(ll i,ll x){
    while(i<=n){
      bit_array[i]+=x;
      i+=(i&(-i));
    }
  }
  ll sum(ll i){
    ll s=0;
    while(i>0){
      s+=bit_array[i];
      i-=(i&(-i));
    }
    return s;
  }
};
struct wBIT{
private:
  ll n;
  vector<BIT> bit_array;
public:
  wBIT(ll s,ll t){
    BIT b=BIT(t);
    bit_array.resize(s+1,b);
    n=s;
  }
  void add(ll i,ll j,ll x){
    while(i<=n){
      bit_array[i].add(j,x);
      i+=(i&(-i));
    }
  }
  ll sum(ll i,ll j){
    ll s=0;
    while(i>0){
      s+=bit_array[i].sum(j);
      i-=(i&(-i));
    }
    return s;
  }
};

int main(){
  ll h,w;
  cin>>h>>w;
  ll mod=1;
  for(int i=0;i<9;i++) mod*=10;
  mod+=7;
  ll hmax[1005],wmax[1005];
  vector<ll> vh,vw;
  for(ll i=0;i<1005;i++){
    for(ll j=0;j<1005;j++) used[i][j]=false;
  }
  for(ll i=1;i<=h;i++){
    cin>>hmax[i];
    vh.push_back(hmax[i]);
  }
  for(ll i=1;i<=w;i++){
    cin>>wmax[i];
    vw.push_back(wmax[i]);
  }
  sort(vh.begin(),vh.end());
  sort(vw.begin(),vw.end());
  for(int i=0;i<h-1;i++){
    if(vh[i]==vh[i+1]){
      cout<<0<<endl;
      return 0;
    }
  }
  ll ans=1;
  wBIT sm=wBIT(h,w);
  for(ll i=1;i<=h;i++){
    for(ll j=1;j<=w;j++) sm.add(i,j,1);
  }
  //cout<<"a"<<endl;
  for(ll i=h*w;i>0;i--){
    ll tat=lower_bound(vh.begin(),vh.end(),i)-vh.begin();
    ll yok=lower_bound(vw.begin(),vw.end(),i)-vw.begin();
    tat++;
    yok++;
    ll pls;
    if(vh[tat-1]==i&&vw[yok-1]==i) pls=1;
    else if(vw[yok-1]==i){
      pls=sm.sum(h,yok)-sm.sum(tat-1,yok)-sm.sum(h,yok-1)+sm.sum(tat-1,yok-1);
    }
    else if(vh[tat-1]==i){
      pls=sm.sum(tat,w)-sm.sum(tat,yok-1)-sm.sum(tat-1,w)+sm.sum(tat-1,yok-1);
    }
    else{
      pls=sm.sum(h,w)-sm.sum(h,yok-1)-sm.sum(tat-1,w)+sm.sum(tat-1,yok-1);
    }
    //cout<<pls<<endl;
    ans*=pls;
    ans%=mod;
    ll x=tat,y=yok;
    sm.add(x,y,-1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <utility>
#include <queue>
#include <tuple>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
constexpr ll INF = 1000000007;

int main() {
    int n, m = 0;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0; i < (n); i++)
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b){
    printf("%d\n",c);
  }else if(a==c){
    printf("%d\n",b);
  }else{
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>

using namespace std;

int DP[2000][2000];

string str[2000];

int min(int a, int b, int c){
	if(a <= b && a <= c){
		return a;
	}else if(b <= c){
		return b;
	}else{
		return c;
	}
}

int main(){
	
	int n, ans;
	
	cin >> n;
	while(n != 0){
		for(int i = 0; i < n; i++){
			cin >> str[i];
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				DP[i][j] = 0;
			}
		}
		
		for(int i = 0; i < n; i++){
			if(str[0][i] == '.'){
				DP[0][i] = 1;
			}else{
				DP[0][i] = 0;
			}
			if(str[i][0] == '.'){
				DP[i][0] = 1;
			}else{
				DP[i][0] = 0;
			}
		}
		
		for(int i = 1; i < n; i++){
			for(int j = 1; j < n; j++){
				if(str[i][j] == '*'){
					DP[i][j] = 0;
				}else{
					DP[i][j] = min(DP[i - 1][j], DP[i][j - 1], DP[i - 1][j - 1]) + 1;
				}
			}
		}
		
		ans = 0;
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(ans < DP[i][j]){
					ans = DP[i][j];
				}
			}
		}
		
		printf("%d\n", ans);
		
		cin >> n;
	}
	
	return 0;
}

Measured memory_bytes: 10424
from collections import deque

class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

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

edges = [[] for _ in range(N + 1)]
tree = UnionFind(N + 1)
for _ in range(M):
    left, right, dist = map(int, input().split())
    edges[left].append((right, dist))
    edges[right].append((left, -dist))
    tree.union(left, right)

minDist = [None] * (N + 1)
for start in range(1, N + 1):
    if tree.root(start) != start:
        continue

    que = deque([(start, 0)])
    while que:
        now, dist = que.popleft()

        if minDist[now] == None:
            minDist[now] = dist
        else:
            if minDist[now] != dist:
                print('No')
                exit()
            continue

        for to, d in edges[now]:
            que.append((to, dist + d))

print('Yes')


Measured memory_bytes: 85188
#include <iostream>

using namespace std;

int main(void){
  int a,b;
cin >> a >> b;
  if(a>b){
    cout <<"a > b" << endl;
  }else if(a<b){
    cout << "a < b"<< endl;
  }else if(a==b){
    cout << "a == b"<<endl;
  }
    return 0;
}

Measured memory_bytes: 3040
taka,yoko=map(int,input().split())

gen=[]
saisho=[]
for i in range(taka):
    s=input()
    temp=[0]*yoko
    for j in range(yoko):
        if(s[j]=="."):
            temp[j]=1
        else:
            temp[j]=-1
    gen.append(temp)
    saisho.append([-1000]*yoko)


if(gen[0][0]==1):
    saisho[0][0]=0
else:
    saisho[0][0]=1


for i in range(1,yoko):
    if(gen[0][i]==1):
        saisho[0][i]=saisho[0][i-1]
    else:
        if(gen[0][i-1]==-1):
            saisho[0][i]=saisho[0][i-1]
        else:
            saisho[0][i]=saisho[0][i-1]+1

for i in range(1,taka):
    if(gen[i][0]==1):
        saisho[i][0]=saisho[i-1][0]
    else:
        if(gen[i-1][0]==-1):
            saisho[i][0]=saisho[i-1][0]
        else:
            saisho[i][0]=saisho[i-1][0]+1


for i in range(1,taka):
    for j in range(1,yoko):
        if(gen[i][j]==1):
            saisho[i][j]=min(saisho[i][j-1],saisho[i-1][j])
        else:
            ue=saisho[i-1][j]
            hidari=saisho[i][j-1]
            if(gen[i-1][j]==1):
                ue+=1
            if(gen[i][j-1]==1):
                hidari+=1
            saisho[i][j]=min(ue,hidari)

print(saisho[taka-1][yoko-1])

Measured memory_bytes: 3316
import itertools
a, b, c, d, e, k = int(input()), int(input()), int(input()), int(input()), int(input()), int(input())

for x, y in list(itertools.combinations([a, b, c, d, e], 2)):
    if y - x > k:
        print(':(')
        exit()
else:
    print('Yay!')

Measured memory_bytes: 3064
#include <stdio.h>

inline void gc(long* x){
    *x = 0;
    for(;;){
        int c=getchar_unlocked();
        if('0'<= c && c <='9'){
            *x = *x*10 + c-'0';
        }else{
            break;
        }
    }
}

int main(void){
    long n, count=-1, old=-1, new;
    gc(&n);
    for(long i=0; i<n; i++){
        gc(&new);
        long d = new-old;
        if(d>=2){
            puts("-1");
            return 0;
        }else if(d==1){
            count++;
        }else{
            count += new;
        }
        old = new;
    }
    printf("%ld\n", count);
    return 0;
}


Measured memory_bytes: 128
n,k = map(int, input().split( ))
r,s,p = map(int, input().split( ))
t = input()
x = []
ans = 0
hand = {"r":"p", "s":"r", "p":"s"}
point = {"r":r,"s":s,"p":p}
for i in range(n):
    h = hand[t[i]]
    if i<k:
        x.append(h)
        ans += point[h]
    else:
        if h !=x[i-k]:
            x.append(h)
            ans += point[h]
        else:
            x.append("x")
print(ans)

        
        


Measured memory_bytes: 45936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>a(N);
    rep(i,N)cin>>a[i];
    sort(all(a));
    ll ans=0;
    rep(i,N-1){
        ans+=a[i+1]-a[i];
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;
 
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
 
typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};
 
ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}
 
 
//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
 
ll dp[100010][4];
int main(){
    int A, B; cin >> A >> B;
    if(A%2==0||B%2==0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  ll m;
  cin >> n >> m;
  ll sub = min(n,m/2);
  ll ans = sub;
  n -= sub;
  m -= 2*sub;
  if (m>0){
    ans += m/4;
  }
  cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  
  if ((S.at(0) == 'A' && S.at(1) == 'A' && S.at(2) == 'A') || 
      (S.at(0) == 'B' && S.at(1) == 'B' && S.at(2) == 'B')) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, K; cin >> N >> K;
    vector<Int> W(N), D(N);
    for (int i = 0; i < N; i++) cin >> W[i] >> D[i];
    Int ng = 0, ok = W[0] + D[0] * K;
    while (ok - ng > 1) {
        Int place = (ok + ng) / 2;
        Int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (place < W[i]) continue;
            cnt += (place - W[i]) / D[i] + 1;
        }
        (cnt >= K ? ok : ng) = place;
    }
    cout << ok << endl;
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

string enc[5] = {"afkpuz","bglqv.","chmrw?","dinsx!","ejoty "};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int w,h;
  while(cin>>s){
    string ans ="";
    bool f = true;
    for(int i = 0; i < s.size();i+=2){
      w = s[i+1]-'0'-1;
      h = s[i]-'0'-1;
      if( !value(w,h,5,6)|| s.size() % 2){
        cout << "NA"<<endl;
        f = false;
        break;
      }
      ans += enc[w][h];
    }
    if(f) cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin >> n >>m;
    int data[100010]={};
    for(int i=0;i<100010;i++){
        data[i]=1;
    }
    data[0]=-1;//red
    int inb,atb;
    for(int i=0;i<m;i++){
        cin >>inb >> atb;
        inb--;
        atb--;
        if(data[inb] <0){
            data[atb]=(abs(data[atb])+1)*-1;
            data[inb]++;
        }else{
            data[inb]--;
            if(data[atb]<0){
                data[atb]--;
            }else{
                data[atb]++;
            }
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(data[i]<0){
            ans++;
        }
    }
    cout << ans<<endl;
}

Measured memory_bytes: 640
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
 
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
 
int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
 
    int i,j,h;
    int Q,K,P,C,N,X;
 
    long double kh,km,A,B;
 
    string S;
    map<long double, ll> m;
 
    cin >> A>>B;
    
 
    cout<<(ll) floor(A*B)<<endl;
    
    return 0;
}

Measured memory_bytes: 3780
#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[100000],t,b[100000];
int main(){
	cin>>n>>t;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll sum=999999999,ans=0;
	for(ll i=0;i<n;i++){
		b[i]=sum;
		sum=min(sum,a[i]);
		ans=max(ans,a[i]-b[i]);
	}
	sum=0;
	for(ll i=0;i<n;i++){
		if((a[i]-b[i])==ans){
			sum++;
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
  
int main(void){
        int a,b,c,i;
        i = 0;
        scanf("%d %d %d",&a,&b,&c);
        while(a <= b){
               if(c % a == 0){
                          i++;
               }
         a++;
         }
        printf("%d\n",i);
        return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main()
{int a[4];
 cin>>a[0]>>a[1]>>a[2];
 sort(a,a+3);
 if(a[0]==5&&a[1]==5&&a[2]==7)
   cout<<"YES"<<endl;
 else
   cout<<"NO"<<endl;
} 

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

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> cnt(26, 0);
    for (int i = 0; i < n; ++ i) {
        string s;
        cin >> s;
        ++ cnt[s[0] - 'A'];
    }
    priority_queue<int> pq;
    for (int i = 0; i < 26; ++ i) if (cnt[i]) pq.push(cnt[i]);

    int ans = 0;
    while ( 1 ) {
        int cc = 0;
        priority_queue<int> tmp;
        while (!pq.empty()) {
            int i = pq.top(); pq.pop();
            if (i > 1) tmp.push(i - 1);
            ++ cc;
            if (cc == k) break;
        }
        while (!tmp.empty()) {
            pq.push(tmp.top()); tmp.pop();
        }

        if (cc ==  k) {
            ++ ans;
        }
        else break;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<long>v(n);
  int i,j,l;
  for(i=0;i<n;i++){
    cin >> v[i];
  }
  long maxx = -9999999999999;
  long tmp = 0;
  priority_queue<long,vector<long>,greater<long>> q;
  for(i=0;i<=min(k,n);i++){
    for(j=0;j<=i;j++){
      tmp = 0;
      for(l=0;l<j;l++){
        q.push(v[l]);
      }
      for(l=0;l<i-j;l++){
        q.push(v[n-1-l]);
      }
      for(l=0;l<k-i;l++){
        if(!q.empty()&&q.top()<0)q.pop();
      }
      while(!q.empty()){
        tmp += q.top();
        q.pop();
      }
      if(tmp>maxx)maxx=tmp;
    }
  }
  cout<<maxx;

}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    x = [0] * N
    y = [0] * N
    z = [0] * N
    for i in range(N):
        x[i], y[i], z[i] = map(int, input().split())

    ans = 0
    for i in [-1,1]:
        for j in [-1,1]:
            for k in [-1,1]:
                cand_list = []
                for n in range(N):
                    tmp = i * x[n] + j * y[n] + k * z[n]
                    cand_list.append(tmp)
                cand_list.sort(reverse=True)
                a = 0
                for m in range(M):
                    a += cand_list[m]
                ans = max(ans, a)

    print(ans)


    


if __name__ == "__main__":
    main()

Measured memory_bytes: 39152
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){


string S,T;
cin >> S >> T;

ll int N;
ll int counter = 0;
N = S.size();
rep(i,N){

if(S[i] != T[i]){
	counter += 1;
}
else{}
}
cout << counter;







	return 0;

}



Measured memory_bytes: 3912
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



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

    P((x-z)/(y+z));
	return  0;
}

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

stock = 0
money = 1000
prev_trend = a[1] - a[0]

if prev_trend > 0:
    stock += money // a[0]
    money -= a[0] * (money // a[0])

if len(a) > 2:
    for i in range(1, n-1):
        next_trend = a[i+1] - a[i]
        if prev_trend >= 0 and next_trend < 0:
            money += a[i] * stock
            stock = 0
        elif prev_trend <= 0 and next_trend > 0:
            stock += money // a[i]
            money -= a[i] * (money // a[i])
        prev_trend = a[i+1] - a[i]

money += a[n-1] * stock
stock = 0

print(money)

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n % 2 == 0) cout << 0.5 << endl;
	else cout << double(double(n / 2 + 1) / n) << endl;
}

Measured memory_bytes: 256
N, *S = open(0)

L = [s.count("(") for s in S]
R = [s.count(")") for s in S]

X = sorted(((s[:-1], r) for s, l, r in zip(S, L, R) if l - r >= 0), key=lambda x: x[1])
Y = sorted(((s[:-1], l) for s, l, r in zip(S, L, R) if l - r < 0), key=lambda x: -x[1])

cnt = 0
for s, _ in X + Y:
    for si in s:
        cnt += 1 if si == "(" else -1
        if cnt < 0:
            print("No")
            quit()

if cnt == 0:
    print("Yes")
else:
    print("No")

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

int main() {
	string s, t;
	cin >> s >> t;
	
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	
	if(s < t){
		cout << "Yes" << endl;
	} else cout << "No" << endl;
	
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
int inf = 6000000000000;
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int solve(vel &list, vel &nex) {
	if (list.size() == 0) { return 0; }
	return find_cr(list[0], nex);
}
signed main(){
	int n; cin >> n;
	pa = vel(n, -1);
	vel nex(n);
	rep(i, n) {
		cin >> nex[i];
		nex[i] += i; nex[i] %= n;
		marge(i, nex[i]);
	}
	vvel list(n);
	rep(i, n) {
		list[root(i)].push_back(i);
	}
	int ans = 0;
	rep(i, n) {
		ans += solve(list[i],nex);
	}
	cout << ans << endl;
	return 0;
}


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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define in_range(x,a,b) ((x>=a) & (x<=b))
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
//#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=1000000;
const int MAXN=1e5+3;

int n,k,ll[MAXN],rl[MAXN],w[MAXN];
vi g[MAXN];

void init(){
	int t1,t2;
	cin>>n;
	rep(i,n-1){
		cin>>t1>>t2;
		g[t1].pb(t2);
		g[t2].pb(t1);
	}
	For(i,n){
		ll[i]=-INF;
		rl[i]=INF;
	}
	cin>>k;
	rep(i,k){
		cin>>t1>>t2;
		w[t1]=t2;
		ll[t1]=rl[t1]=t2;
	}
}

void calc_range(int x,int p){
	for (int i:g[x]){
		if (i==p) continue;
		calc_range(i,x);
		if (ll[i]==-INF && rl[i]==INF) continue;
		ll[x]=max(ll[x],ll[i]-1);
		rl[x]=min(rl[x],rl[i]+1);
		if (ll[i]%2==ll[x]%2){
			cout<<"No";
			exit(0);
		}
	}
	if (ll[x]>rl[x]){
		cout<<"No";
		exit(0);
	}
}

void make(int x,int p){
	if (!w[x]){
		w[x]=ll[x];
	}
	for (int i:g[x]){
		if (i==p) continue;
		if (in_range(w[x]+1,ll[i],rl[i])){
			w[i]=w[x]+1;
		}else{
			w[i]=w[x]-1;
		}
		make(i,x);
	}
}

int main(){
	init();
	calc_range(1,-1);
	make(1,-1);
	cout<<"Yes"<<endl;
	For(i,n){
		cout<<w[i]<<endl;
	}
	re 0;
}

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

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

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

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

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

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

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

int main()
{
  ll a,b,w;
  cin >> w >> a >> b;
  if(b+w<a)printf("%lld",a-b-w);
  else if(a+w<b)printf("%lld",b-a-w);
  else printf("0");
}

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

using namespace std;

int main(){

  int n=0;
  string s;
  cin >> s;
  int length = s.size();
  int count1 = 0;
  int count2 = length;

while(s[n] != 0){
  if(s[n] == 'A') break;
  n++;
  count1++;
}

n = length;
while(s[n-1] != 0){
  if(s[n-1] == 'Z') break;
  n--;
  count2--;
}

  cout << count2 - count1 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, p; cin >> n >> p;
	int ans = 1;
	map<int, int>mp;
	for (int i = 2; i <= sqrt(p); i++) {
		if (!prime(i))continue;
		while (p%i == 0) {
			mp[i]++; p /= i;
		}
		ans *= pow(i, mp[i] / n);
	}
	if (p != 1) {
		mp[p] = 1;
	}
	ans *= pow(p, mp[p] / n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007

    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n,k;
        cin>>n>>k;
        if(k==1) return cout<<0,0;
        n-=k;

        cout<<max(0,n);
         
     }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define PB push_back
#define POB pop_back
#define UB upper_bound
#define LB lower_bound
#define MP make_pair
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define SORT(v) sort((v).begin(),(v).end())
#define REV(v) reverse((v).begin(),(v).end())
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,i;
  VL L(90);
  cin>>N;
  L[0]=2,L[1]=1;
  FOR(i,2,N+1)L[i]=L[i-1]+L[i-2];
  cout<<L[N]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
    ll n,k; cin >> n >> k;
    vl a(n); rep(i,n) cin >> a[i];
    double ans = 0;
    rep(i,k) ans += (1+a[i])/(double)2;
    double sum = ans;
    rep(i,n-k){
        sum -= (1+a[i])/(double)2;
        sum += (1+a[i+k])/(double)2;
        chmax(ans,sum);
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
int main(void){
    int N;
    int A[200000];
    scanf("%d",&N);
    ll length = 0;
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
        length += A[i];
    }
    ll left = A[0]; ll right = length - left;
    ll min = llabs(left - right);
    for(int i=1;i<N;i++){
        left += A[i];
        right -= A[i];
        if(min > llabs(left - right)){
            min = llabs(left - right);
        }
    }
    printf("%lld\n",min);
    return 0;
}


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

q = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    q.append(array)

q = sorted(q, key=lambda x: x[1])

t = 0
flag = True
for i in range(N):
    t += q[i][0]
    if t > q[i][1]:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 56624
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll,ll> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else 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;
}

int main() {
    ll A, B;
    cin >> A >> B;
    if(A>B) {
        cout << 2 * A - 1 << endl;
    }else if(A<B){
        cout << 2 * B - 1 << endl;
    }else{
        cout << 2*A  << endl;
    }
    return 0;
}


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


def main():
    s = input()

    # See:
    # https://atcoder.jp/contests/abc175/editorial/51
    # 1. 各文字がRと一致しているか
    # 2. 何文字一致しているか、を条件分岐
    first = s[0] == 'R'
    second = s[1] == 'R'
    third = s[2] == 'R'

    if first and second and third:
        print(3)
    elif (first and second) or (second and third):
        print(2)
    elif (first or second or third):
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8948