akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[1000],n,p,q,r;
  while(cin>>n&&n){
    for(i=0;i<n;i++){
      cin>>p>>q>>r;
      if(p==100||q==100||r==100)
	a[i]=0;
      else if(p+q>179)
	a[i]=0;
      else if(p+q+r>239)
	a[i]=0;
      else if(p+q+r>209)
	a[i]=1;
      else if(p+q+r>149&&(p>79||q>79))
	a[i]=1;
      else
	a[i]=2;
    }
    for(i=0;i<n;i++)
      cout<<(char)('A'+a[i])<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define int long long

signed main() {
	int tmp[100000] = {};
	int a, b, c;
	cin >> a >> b >> c;
	tmp[a]++;
	tmp[b]++;
	tmp[c]++;
	if (tmp[5] == 2 && tmp[7] == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}



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

int main() {
  int r; cin >> r;
  cout << r * r << endl;
}



Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] price = new int[N];
    int sum = 0;
    int max = 0;
    for(int i=0; i<N; i++){
      int tmp = sc.nextInt();
      sum += tmp;
      price[i] = tmp;
      max = Math.max(tmp, max);
    }
    sum = sum - max + (max/2);
    System.out.print(sum);
  }
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int tbl[20][20];
int cleartbl[1<<16][16];
int memo[1<<16];
int n;
int dist(int b){
  if(b==0) return 0;
  if(memo[b]) return memo[b];
  int ret = 1<<28;
  for(int i=0;i<n;++i)
    if((b>>i)&1)
      ret = min(ret,dist(b-(1<<i))+cleartbl[b-(1<<i)][i]);
  return memo[b]=ret;
}
int solve(){
  for(int i=0;i<1<<n;++i){
    for(int j=0;j<n;++j){
      cleartbl[i][j] = tbl[j][0];
      for(int k=0;k<n;++k)
	if((i>>k)&1)
	  cleartbl[i][j] = min(cleartbl[i][j],tbl[j][k+1]);
    }
  }
  memset(memo,0,sizeof(memo));  
  return dist((1<<n)-1);
}
int main(){
  while(cin >> n,n){
    for(int i=0;i<n;++i)
      for(int j=0;j<=n;++j)
	cin >> tbl[i][j];
    cout << solve()<< endl;
  }
  
  return 0;
}

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

int mynot(int i){
  return 2 - i;
}

int myand(int i, int j){
  if(i == 2 && j == 2){return 2;}
  if(i == 0 || j == 0){return 0;}
  return 1;
}

int myor(int i, int j){
  if(i == 0 && j == 0){return 0;}
  if(i == 2 || j == 2){return 2;}
  return 1;
}

int interp(int P, int Q, int R, char* formula){
  char* snd;
  int   lcnt = 0;
  int   ptr  = 0;

  switch(formula[0]){
    case '0':
      return 0;
      break;
    case '1':
      return 1;
      break;
    case '2':
      return 2;
      break;
    case 'P':
      return P;
      break;
    case 'Q':
      return Q;
      break;
    case 'R':
      return R;
      break;
    case '-':
      return mynot(interp(P, Q, R, formula + 1));
      break;
    case '(':
      int left, right;
      ptr++;

        if(formula[ptr] == '('){
          int cnt = 1; ptr++;
          while(cnt != 0){
            if( formula[ptr] == '(' ){cnt++;}
            if( formula[ptr] == ')' ){cnt--;}
            ptr++;
          }
        }else if(formula[ptr] == '-'){
          while(formula[ptr] == '-'){ptr++;}

          if(formula[ptr] == '('){
            int cnt = 1; ptr++;
            while(cnt != 0){
              if( formula[ptr] == '(' ){cnt++;}
              if( formula[ptr] == ')' ){cnt--;}
              ptr++;
            }
          }else{ptr++;}
        }else{
          ptr++;
        }

      if(formula[ptr] == '*'){
        left  = interp(P, Q, R, formula + 1);
        right = interp(P, Q, R, formula + ptr + 1);
        return myand(left, right);
      }
      if(formula[ptr] == '+'){
        left  = interp(P,Q,R, formula + 1);
        right = interp(P,Q,R, formula + ptr + 1);
        return myor(left, right);
      }
    }
}


int main(void){
  while(1){
    char formula[80];
    cin >> formula;
    if(formula[0] == '.') return 0;

    int cnt = 0;
    for(int i = 0; i < 3 ; i++){
      for(int j = 0; j < 3 ; j++){
        for(int k = 0; k < 3 ; k++){
          if(interp(i,j,k,formula) == 2) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 3068
import java.util.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        
        System.out.print(s1.toUpperCase().charAt(0));
        System.out.print(s2.toUpperCase().charAt(0));
        System.out.print(s3.toUpperCase().charAt(0));
    }
}

Measured memory_bytes: 35588
n = int(input())
ox = str(input())
ans = -1
ss = [1, 1]
sw = [1, -1]
ws = [-1, 1]
ww = [-1, -1]
line = [ss, sw, ws, ww]

for c in ox[1:]:
    for s in line:
        if c == "o":
            if s[-1] == 1:
                s.append(s[-2])
            else:
                s.append(s[-2] * -1)
        else:
            if s[-1] == -1:
                s.append(s[-2])
            else:
                s.append(s[-2] * -1)

for s in line:
    if s[0] == s[-1]:
        if ox[0] == "o":
            if (s[0] == 1 and s[1] == s[-2]) or (s[0] == -1 and s[1] != s[-2]):
                ans = ""
                for i in s[:-1]:
                    if i == 1:
                        ans += "S"
                    else:
                        ans += "W"
        else:
            if (s[0] == -1 and s[1] == s[-2]) or (s[0] == 1 and s[1] != s[-2]):
                ans = ""
                for i in s[:-1]:
                    if i == 1:
                        ans += "S"
                    else:
                        ans += "W"
print(ans)


Measured memory_bytes: 7212
#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int maxn=2e5+7;
int a[maxn];


int main (){
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	int r=1,i=0;
	ll now=a[0],ans=0;
	while(i<n){
		if(r<n&&(now&a[r])==0){
			now+=a[r];
			r++;
		}
		else {
			now-=a[i];
			ans+=r-i;
			i++;
			if(i>=r) {
				r=i+1;
			    now=a[i];
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#define MAX_W 30
#define MAX_N 30
using namespace std;

typedef pair<int, int> P;
P line[MAX_N + 1];
int n, w;
char comma;
int result[MAX_W + 1];

void input()
{
	cin >> w >> n;
	for (int i = 1; i <= n; i++)
		cin >> line[i].first >> comma >> line[i].second;
}

void solve()
{
	int pos;
	for (int i = 1; i <= w; i++)
	{
		pos = i;
		for (int j = 1; j <= n; j++)
		{
			if (line[j].first == pos)
				pos = line[j].second;
			else if (line[j].second == pos)
				pos = line[j].first;
		}
		result[pos] = i;
	}
}

void print()
{
	for (int i = 1; i <= w; i++)
		cout << result[i] << endl;
}

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

Measured memory_bytes: 1160
# define _SCL_SECURE_NO_WARNINGS

# include <iostream>
# include <string>
# include <iomanip>
# include <stdio.h>
# include <array>
# include <numeric>
# include <algorithm>
# include <vector>
# include <functional>



using Ull = unsigned long long;
using Ll = long long;

//namespace TechFUL_i4
//{

namespace mine
{

    template<typename T>
    std::istream& operator >> (std::istream& is, std::vector<T>& vec)
    {
        for (T& x : vec) is >> x;
        return is;
    }

    template<typename T>
    std::string to_string(std::vector<T> vec, std::string sep = " ")
    {
        std::string result;
        for (T& x : vec) result += std::to_string(x) + sep;
        result.erase(result.size() - sep.length());

        return result;
    }

    template<typename T, size_t L>
    std::string to_string(T(&ary)[L], std::string sep = " ", size_t size = L)
    {
        std::string result;
        for (int i = 0; i < size; ++i) result += std::to_string(ary[i]);
        result.erase(result.size() - sep.length());

        return result;
    }

    template<typename T, size_t L, typename Function>
    void for_each(T(&ary)[L], Function lambda)
    {
        for (size_t i{}; i < L; ++i)
            lambda(static_cast<T&>(ary[i]));
    }

    template<typename T>
    void SetAll(T container, typename T::value_type value = typename T::value_type{})
    {
        for (typename T::reference content : container)
            content = value;
    }

    template<typename T, size_t L>
    void SetAll(T(&ary)[L], T value = T{})
    {
        for (size_t i{}; i < L; ++i)
            ary[i] = value;
    }

    template<typename T, size_t L>
    std::array<T, L> AsContainer(T(&ary)[L], bool isSwap = true)
    {
        std::array<T, L> result;

        if (isSwap)
        {
            for (size_t i{}; i < L; ++i)
                std::swap(result[i], ary[i]);
        }
        else
        {
            for (size_t i{}; i < L; ++i)
                result[i] = ary[i];
        }

        return result;
    }

    template<size_t length>
    constexpr std::array<size_t, length> range()
    {
        std::array<size_t, length> range{};

        for (size_t i{}; i < length; ++i)
            range[i] = i;

        return range;
    }

    template<typename T>
    const std::vector<T> range(const T length)
    {
        std::vector<T> range(length);

        for (T i{}; i < length; ++i)
            range[i] = i;

        return range;
    }

    /// <summary>
    /// 最初と最後を含める
    /// </summary>
    /// <param name="start"></param>
    /// <param name="end"></param>
    /// <returns></returns>
    template<typename T>
    const std::vector<T> range(const T start, const T end)
    {
        std::vector<T> range(end - start + 1);

        for (T i{start}; i <= end; ++i)
            range[i] = i;

        return range;
    }

}
using namespace mine;


//namespace B
//{
int main()
{
    std::vector<Ull> data(3);
    int K;
    std::cin >> data >> K;

    auto pos = std::max_element(data.begin(), data.end());
    for (auto i : range(K)) *pos *= 2;

    std::cout << std::accumulate(data.begin(), data.end(), 0);

    return 0;
}
//}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.array, std.conv;

void main() {
  int times = readln.chomp.to!(int);
  foreach(t; 0..times) {
    double[] p = readln.chomp.split(" ").map!(to!(double)).array;
    bool ans;
    if ((p[0] - p[2]) == 0 && (p[4] - p[6]) == 0) ans = true;
    else if ((p[0] - p[2]) == 0 || (p[4] - p[6]) == 0) ans = false;
    else if
      (((p[1] - p[3]) / (p[0] - p[2])) == ((p[5] - p[7]) / (p[4] - p[6])))
      ans = true;
    else ans = false;
    writeln(ans ? "YES" : "NO");
  }
}

Measured memory_bytes: 1076
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
typedef long long ll;
string s[maxn];
int f[3];//f[0] B A f[1] B f[2] A 
int v[15];
int main()
{
	int n;cin>>n;int ans=0;
	for(int i=0;i<n;i++)
	{
		memset(v,0,sizeof(v));
		cin>>s[i];int len=s[i].length();
		for(int j=0;j<len-1;j++)
		{
			if(s[i][j]=='A'&&s[i][j+1]=='B')
			{
				ans++;v[j]=1;v[j+1]=1;
			}
		}
		if(s[i][0]=='B'&&s[i][len-1]=='A'&&v[0]==0&&v[len-1]==0) f[0]++;
		else if(s[i][0]=='B'&&v[0]==0)  f[1]++;
		else if(s[i][len-1]=='A'&&v[len-1]==0) f[2]++;
	}
	//cout<<ans<<" "<<f[0]<<" "<<f[1]<<" "<<f[2]<<endl;
	if(f[0]!=0)
	{
		if(f[1]==0&&f[2]==0) cout<<ans+f[0]-1<<endl;
	else if(f[1]==0&&f[2]!=0) cout<<ans+f[0]<<endl;
	else if(f[1]!=0&&f[2]==0) cout<<ans+f[0]<<endl;
	else cout<<(ans+f[0]+1+min(f[1]-1,f[2]-1))<<endl;
	}
	else
	{
		cout<<(ans+min(f[1],f[2]))<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 1536
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	G
# CreatedDate:  2020-05-18 17:21:29 +0900
# LastModified: 2020-05-19 01:07:59 +0900
#


import os
import sys
from collections import deque
#import numpy as np
#import pandas as pd
def chmax(s,t):
    if s<t:
        return t
    else:
        return s


def longest_path(ans_list,node_list,lon_path):
    while ans_list:
        u = ans_list.pop()
        for v,_from in enumerate(node_list):
            if u in _from and lon_path[v]<lon_path[u]+1:
                lon_path[v]=lon_path[u]+1
    print(max(lon_path))

def main():
    n,m = map(int,input().split())
    node_list = [[] for _ in range(n+1)]
    to_count = [0]*(n+1)
    for _ in range(m):
        s,t = map(int,input().split())
        node_list[s].append(t)
        to_count[t]+=1
    q = deque()
    for i,x in enumerate(to_count):
        if x==0:
            q.append(i)
    q.popleft()
    distance = [0]*(n+1)
    ans_list = []
    while q:
        u = q.popleft()
        for v in node_list[u]:
            to_count[v]-=1
            if to_count[v]==0:
                q.append(v)
                distance[v]=chmax(distance[v],distance[u]+1)
        ans_list.append(u)
    print(max(distance))
#    longest_path(ans_list,node_list,lon_path)

if __name__ == "__main__":
    main()


Measured memory_bytes: 23860
n, m = map(int, input().split())
 
s, c = [], []
for _ in range(m):
  s_, c_ = map(int, input().split())
  s.append(s_)
  c.append(c_)
 
for i in range(10**n):
  ans = str(i)
  if len(ans) == n and all([ans[s[j]-1] == str(c[j]) for j in range(m)]):
    print(ans)
    exit()
 
print(-1)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  
  vector<int> cont(m);
  for(int i = 0 ; i < m ; i++){
    cin >> cont.at(i);
  }
  
  sort(cont.begin() , cont.end());
  
  if(n >= m){
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> aaa(m-1);
  
  for(int i = 0 ; i < m-1 ; i++){
    aaa.at(i) += cont.at(i+1) - cont.at(i);
  }
  
  sort(aaa.begin() , aaa.end());
  reverse(aaa.begin() , aaa.end());
  
  int ans = cont.at(m-1) - cont.at(0);
  
  for(int i = 0 ; i < n-1 ; i++){
    ans -= aaa.at(i);
  }
  cout << ans << endl;
}

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

int main(){
 int N,M;
 cin >> N >> M;
 int O[M];
 for(int i = 0;i<M;i++){
   cin >> O[i];
 }
 for(int j=M-1;j>=0;j--){
   N -= O[j];
 }
 if(N<0){
   cout << "-1" << endl;
 }
 else{
   cout << N << endl;
 }

}

Measured memory_bytes: 3640
#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 rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

int kaijo(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main() {
    int n; cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> order(n);
    rep(i,n) order[i]=i+1;
    int a,b;
    int count=1;
    do{
        if(p==order) a=count;
        if(q==order) b=count;
        count++;
    }while(next_permutation(all(order)));

    COUT(abs(a-b));
}

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


int main(){
  int n;
  cin >> n;
  vector<ll> a(n),t(n);
  for(int i=0;i<n;++i){
    cin >> a[i] >> t[i];
  }
  ll x=1;
  ll y=1;
  ll N=1;
  for(int i=0;i<n;++i){
    if(i==0) N=1;
    else N=max((a[i-1]*N+a[i]-1)/a[i],(t[i-1]*N+t[i]-1)/t[i]);

    x=a[i]*N;
    y=t[i]*N;
  }
  cout << x+y << endl;
  return 0;
}


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

int main() {
    int r,d,x;
    cin>>r>>d>>x;
    
    int a[15];
    a[0]=x;
    
    for(int i=1;i<=10;i++)
    {
        a[i]=r*a[i-1] - d;
        cout<<a[i]<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
def Get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def Get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def Get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def Get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end

n=gets.to_i
k=gets.to_i
a=Get_i()

ans=0
n.times do|i|
  if a[i]<(k-a[i]).abs
    ans+=a[i]*2
  else
    ans+=(k-a[i]).abs*2
  end
end
puts ans


Measured memory_bytes: 1788
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  
  string s ;
  cin >> s ;
  
  int dif = abs(stoi(s.substr(0,3)) - 753) ;  
  
  for(int i=1 ; i<=(s.length()-2) ; i++){
    int num = abs(stoi(s.substr(i,3)));
    if(dif>abs(num - 753)){
      dif = abs(num - 753) ;
    }
  }
  
  cout << dif << endl ;
  
  return 0 ;
}


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

First=set()
Second=set()

for i in range(M):
  a,b=map(int,input().split())
  if a==1 or b==1:
    First.add(max(a,b))
  elif a==N or b==N:
    Second.add(min(a,b))

Ans= First & Second

if len(Ans):
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

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

using namespace std;

#define ll long long
#define sf scanf
#define pf printf 
#define nl printf("\n")
#define pi acos(-1)

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif

    double r;
    while(cin>>r){
        pf("%lf\n",(2*pi*r));
    }
    return 0;
}

Measured memory_bytes: 3788
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
using namespace std;
typedef long long ll;
int main() {
    int a, b;
    cin >> a >> b;

    int d = a / b;
    int r = a % b;
    double f = (double)a / b;
    cout.precision(5);
    cout << fixed << d << " " << r << " " << f << endl;

    return 0;
}

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

string str,f,b;
int N,koko,memo;

int main(){

    while(1){
        koko = 0;
        cin >> str;
        if(str == "-") break;
        cin >> N;
        for(int i = 0; i < N; ++i){
            cin >> memo;
            koko += memo;
        }
        koko = koko % str.length();

        f = str.substr(0,koko);
        b = str.substr(koko,str.length() - koko);
        cout << b << f << endl;
    }
    return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) int(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }

//ll f[200005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

ll dp(ll x) {
	if (x == 1)
		return 1;
	return 2 * dp(x / 2) + 1;
}

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE

	fastio;
	ll h;
	cin >> h;
	cout << dp(h);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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


int main() {

	int a, b, c,empty;
	int ans;
	cin >> a >> b >> c;
	empty = a - b;
	ans = c - empty;
	ans = max(ans, 0);
	cout << ans;

}

Measured memory_bytes: 256
N, C = map(int, input().split())
Xi = [list(map(int, input().split())) for _ in range(N)]

#両端に(0,0)があると考えると楽なので追加
Xi.insert(0, [0, 0])
Xi.append([C, 0])

# 真上に0があると考える。下から⇢にいくか←にいくかで区別
#右方向に進んだときの累積Caloryと累積max
total = 0
R_max = [0 for i in range(N + 2)]
for i in range(1, N + 1):
    total += Xi[i][1] - (Xi[i][0] - Xi[i - 1][0])
    R_max[i] = max(total, R_max[i - 1])

#右方向に進んだときの累積max
total = 0
L_max = [0 for i in range(N + 2)]
for i in range(N, 0, -1):
    total += Xi[i][1] - (Xi[i + 1][0] - Xi[i][0])
    L_max[i] = max(total, L_max[i + 1])

max_value = 0
for i in range(0, N + 1):
    i2 = N - i - 1
    #右方向にとにかくすすむ
    cal = R_max[i] + L_max[i + 1] - Xi[i][0]
    max_value = max(cal, max_value)

    #左にとにかくすすむ
    cal = R_max[i] + L_max[i + 1] - (C - Xi[i + 1][0])
    max_value = max(cal, max_value)
print(max_value)

Measured memory_bytes: 36812
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
int main(){
  string s;cin>>s;
  rep(i,s.size()-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	double[] a = new double[n];
    	int[] b = new int[n];
    	double[] c = new double[n];
    	Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
    	Arrays.setAll(b, i -> Integer.parseInt(sc.next()));
    	Arrays.setAll(c, i -> Integer.parseInt(sc.next()));
    	Arrays.sort(a);
    	Arrays.sort(b);
    	Arrays.sort(c);
    	long ans = 0;
    	for(int i = 0; i < n; i++) {
    		int idxA = ~Arrays.binarySearch(a, b[i] - 0.1);
    		if(idxA < 0) continue;
    		long A = idxA;
    		
    		int idxC = ~Arrays.binarySearch(c, b[i] + 0.1);
    		if(idxC < 0) continue;
    		long C = n - idxC;
    		
    		ans += A*C;
    	}
    	System.out.println(ans);
    }
}


Measured memory_bytes: 66676
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
    long long a,b,x,ans;
    cin>>a>>b>>x;
    if (a==0){
        ans =((b/x)+1);
    }
    else{
        ans = ((b/x)+1) - (((a-1)/x)+1);
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int D;
    cin >> D;
    if (D == 22)
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    else if (D == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    else if (D == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    else
    {
        cout << "Christmas" << endl;
    }
}

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

dp = [float('inf')] * (N+1)
dest = [1]
dp[0] = 0
for i in range(1,10):
    if 6 ** i <= N:
        dp[6 ** i] = 1
        dest.append(6 ** i)
    else:
        break
    if 9 ** i <= N:
        dp[9 ** i] = 1
        dest.append(9 ** i)

for i in range(N+1):
    for j in dest:
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i-j]+1)
    
print(dp[N])

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main(){
  int N, A[1010];
  cin>>N;
  for (int i=0; i<N; i++) cin>>A[i];
  bool gri=true;
  for (int i=0; i<N; i++) {
    if (A[i]%2==0 && A[i]%3!=0 && A[i]%5!=0) gri=false;
  }
  if (gri) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}
  

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

using namespace std;


int main(void) {
    char c;
    cin >> c;

    switch (c) {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
        cout << "vowel" << endl;
        break;
    default:
        cout << "consonant" << endl;
        break;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
total = set()
def check(x):
    if x.count('7') and x.count('5') and x.count('3'):
        return True
    else:
        return False

def dfs(a):
    if len(a) > len(str(n)):
        return

    for i in ['7', '5', '3']:
        a += i
        if int(a) <= n and check(a):
            total.add(a)
        dfs(a)
        a = a[:-1]


dfs('')
print(len(total))

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

int abs(int x){return x>0?x:-x;}

int main(){
  string s;
  cin>>s;
  int ans=1000;
  for(int i=0;i+2<s.size();i++){
    int t=0;
    for(int k=0;k<3;k++)t+=(s[i+k]-'0')*pow(10,2-k);
    ans=min(abs(t-753),ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = get!([i32]);
    let mut l = 0;
    let mut lflag = false;
    let mut r = 0;
    let mut rflag = false;
    let mut count = 0;
    loop {
        if !lflag {
            for i in 0..n {
                if v[i] != 0 || i == n - 1 {
                    l = i;
                    lflag = true;
                    break;
                }
            }
        } else {
            for i in l..n {
                if v[i] == 0 {
                    r = i;
                    rflag = true;
                    break;
                }
                if i == n - 1 {
                    r = i + 1;
                    rflag = true;
                    break;
                }
            }
        }
        if rflag && lflag {
            //eprintln!("{:?}", v);
            //eprintln!("l: {}, lflag: {}", l, lflag);
            for i in l..r {
                v[i] -= 1;
            }
            lflag = false;
            rflag = false;
            count += 1;
        }

        //終了条件
        if l == n - 1 && v[n - 1] == 0 {
            break;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <stdio.h>

void trace(int A[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int j, i, v;
    for (int i = 0; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main() {
    int N,i,j;
    int A[100];

    scanf("%d", &N);
    for (int i = 0; i < N; ++i) scanf("%d", &A[i]);

    //trace(A,N);
    insertionSort(A,N);

    return 0;

}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x[102];
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    if (x[i] * 2 <= (k - x[i]) * 2) {
      ans += x[i] * 2;
    }
    else {
      ans += (k - x[i]) * 2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
input = []
result = 0
for i in 0..n-1
	input.push(gets.to_i)
end
input.sort!

for i in 0..n-1
	if input[i] == input[i+1]
		input.delete_at(i+1)
	else
		result += 1
	end
end
puts result


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

const int N = 100;
int mat[N][N];
int dist[N][N];

// i, j
vector<pii> dir = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main(){
    fcin;
    int n, m;
    cin >> n >> m;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            char c; cin >> c;
            mat[i][j] = (c == '.' ? 0 : 1);
        }
    }

    int ii = 0, jj = 0;
    int M = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(mat[i][j] == 0) ii = i, jj = j;

            queue<pii> q;
            q.push({ii, jj});
            memset(dist, INF, sizeof dist);
            dist[ii][jj] = 0;

            auto check = [&](int i, int j){
                return i >= 0 and i < n and j >= 0 and j < m and mat[i][j] != 1;
            };

            while(q.size()){
                pii p = q.front();
                q.pop();

                for(auto d : dir){
                    pii nxt = {p.fi + d.fi, p.se + d.se};
                    if(check(nxt.fi, nxt.se) and dist[nxt.fi][nxt.se] == INF){
                        dist[nxt.fi][nxt.se] = dist[p.fi][p.se] + 1;
                        q.push(nxt);
                    }
                }
            }

            int Mn = 0;
            for(int i = 0; i < n; i++){
                for(int j = 0; j < m; j++){
                    if(dist[i][j] != INF and dist[i][j] > M){
                        Mn = max(Mn, dist[i][j]);
                        ii = i, jj = j;
                    }
                }
            }

            q.push({ii, jj});
            memset(dist, INF, sizeof dist);
            dist[ii][jj] = 0;

            while(q.size()){
                pii p = q.front();
                q.pop();

                for(auto d : dir){
                    pii nxt = {p.fi + d.fi, p.se + d.se};
                    if(check(nxt.fi, nxt.se) and dist[nxt.fi][nxt.se] == INF){
                        dist[nxt.fi][nxt.se] = dist[p.fi][p.se] + 1;
                        q.push(nxt);
                    }
                }
            }

            for(int i = 0; i < n; i++){
                for(int j = 0; j < m; j++){
                    if(dist[i][j] != INF and dist[i][j] > M){
                        M = max(M, dist[i][j]);
                    }
                }
            }
        }
    }

    cout << M << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static final int MAX = 10;
    static final int INF = 1 << 21;
    static final int WHITE = 0;
    static final int GRAY = 1;
    static final int BLACK = 2;
    static int n = 10;
    static int[][]M;;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] c = new int[10][10];
		int[][] A = new int[H][W];
		for(int i = 0; i < 10; i++) {
			for(int j= 0; j < 10; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < H; i++) {
			for(int j= 0; j < W; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		sc.close();
		M = c;
		int[] d = new int[10];
		for(int i = 0; i <10; i++) {
			if(i == 1) d[i] = 0;
			else {
				d[i] = dijkstra(i);
			}
		}
		int sum = 0;
		for(int i = 0; i < H; i++) {
			for(int j= 0; j < W; j++) {
				if(A[i][j] != -1 && A[i][j] != 1) {
					sum += d[A[i][j]];
				}
			}
		}
		System.out.println(sum);
	}
	static int dijkstra(int t) {
        int minV;
        int[]d = new int [MAX];
        int[]color = new int [MAX];
        for(int i = 0; i < n; i++) {
            d[i] = INF;
            color[i] = WHITE;
        }
        d[t] = 0;
        color[t] = GRAY;
        while(true) {
            minV = INF;
            int u = -1;
            for(int i = 0; i < n; i++) {
                if(minV > d[i] && color[i] != BLACK) {
                    u = i;
                    minV = d[i];
                }
            }
            if(u == -1) break;
            color[u] = BLACK;
            for(int v = 0; v < n; v++) {
                if(d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
        return d[1];
    }
}

Measured memory_bytes: 47520
#include <bits/stdc++.h>
using namespace std;
#define  ll long long int
int main(){
    ll n,m;
    cin>>n>>m;
    ll ar[m];
    ll sum=n;
    for(ll i=0;i<m;i++) {
        cin >> ar[i];
        sum=sum-ar[i];
    }
    if(sum>=0)
        cout<<sum<<endl;
    else
        cout<<"-1"<<endl;
    return 0;
}


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

using namespace std;

int n,k;
vector<int> w;

int count(int p){
	vector<int> hoge(k,0);
	auto it=hoge.begin();
	int cnt=0;

	for(int i=0;i<n;i++){
		int box=w.at(i);
		if(box>p) break;

		if(*it+box>p) it++;
		if(it==hoge.end()) break;

		*it+=box;
		cnt++;
	}

	return cnt;
}

int main(){
	cin>>n>>k;
	int maxw=0;

	for(int i=0;i<n;i++){
		int meta;
		cin>>meta;
		w.push_back(meta);
		maxw+=meta;
	}

	int l=1,r=maxw;

	while(l<r){
		int mid=(l+r)/2;
		int cnt=count(mid);

		if(cnt==n){
			r=mid;
		}else if(cnt<n){
			l=mid+1;
		}
	}

	cout<<r<<endl;

	return 0;
}



Measured memory_bytes: 3644
import itertools
import math

N = int(input())
permutation = list(itertools.permutations([x for x in range(1, N + 1)]))
coordinate = [list(map(int, input().split())) for _ in range(N)]
distances = []

for one_case in permutation:
    sum_dis = 0
    for j in range(N - 1):
        dis = math.sqrt((coordinate[one_case[j] - 1][0] - coordinate[one_case[j + 1] - 1][
            0]) ** 2 + (coordinate[one_case[j] - 1][1] - coordinate[one_case[j + 1] - 1][
            1]) ** 2)
        sum_dis += dis
    distances.append(sum_dis)
print('{:.7f}'.format(sum(distances) / len(permutation)))


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

int N, MOD;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

const int MAX = 100000; 
vector<int> edges[MAX];
int64_t dp[MAX], ans[MAX];
vector<int64_t> left[MAX], right[MAX];

void dfs(int i, int p){
    dp[i] = 1;
    for(int j : edges[i]){
        if(j==p) continue;
        dfs(j, i);
        mul(dp[i], dp[j]+1);
    }
}

void dfs2(int i, int p, int64_t top){
    ans[i] = dp[i] * (top+1) % MOD;
    vector<int64_t> vals = {0};
    for(int j : edges[i]) if(p!=j) vals.push_back(dp[j]+1);
    int sz = vals.size() - 1;
    vector<int64_t> lp(sz+2, 1), rp(sz+2, 1);
    for(int pt=1; pt<=sz; pt++) lp[pt] = lp[pt-1] * vals[pt] % MOD;
    for(int pt=sz; pt>0; pt--) rp[pt] = rp[pt+1] * vals[pt] % MOD;
    int pt = 1;
    for(int j : edges[i]){
        if(p==j) continue;
        int64_t tp2 = (top+1) * lp[pt-1] % MOD * rp[pt+1] % MOD;
        dfs2(j, i, tp2);
        pt++;
    }
}

int main(){
    cin >> N >> MOD;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    dfs(0, -1);
    dfs2(0, -1, 0);
    for(int i=0; i<N; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 30208
#A問題
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

p1 = P*A
p2 = 0
if P > C:
    p2 = B + (P-C)*D
else:
    p2 = B
    
print(min(p1,p2))



Measured memory_bytes: 5592
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    ll n, y;

    cin >> n >> y;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            for (int k = 0; k <= n; k++)
            {
                if (i + j + k > n)
                    break;
                else if (i + j + k < n)
                    continue;
                else
                {
                    if (i * 1000 + j * 5000 + k * 10000 == y)
                    {
                        cout << k << " " << j << " " << i << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
from functools import reduce
N,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))

def gcd (a,b):
    if a < b:
        a,b = b,a
    return a if b == 0 else gcd(b,a%b)

v = reduce(lambda a,b:gcd(a,b) , A)
if K % v == 0 and max(A) >= K :
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main() {
    int n;
    cin >> n;
    vector<pair<string, int>> ms;
    for (int i=0; i<n; i++) {
        string s; int t;
        cin >> s >> t;
        ms.push_back(make_pair(s, t));
    }
    string x;
    cin >> x;
    bool is_sleep = false;
    int ans = 0;
    for (int i=0; i<n; i++) {
        if (is_sleep) {
            ans += ms[i].second;
            continue;
        }
        if (ms[i].first == x) is_sleep = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
     long long int k,s,i,j,a[7777],sn,sum;
        cin>>k>>s;
         for(i=0;i<=7500;i++)
            a[i]=0;
         sn=0;
         for(i=0;i<=k;i++)
         {
             for(j=0;j<=k;j++)
             {
                 a[i+j]++;
             }
         }
         for(i=0;i<=k;i++)
         {
             sum=s-i;
             if(sum>=0)
             sn+=a[sum];
         }
       cout<<sn<<endl;
     return 0;
}

Measured memory_bytes: 256
S = list(input())

false_flag = 0
for i, char in enumerate(S):
    #print(i, char)
    if i % 2 == 0:
        if char == 'L':
            false_flag = 1
            break
    if i % 2 == 1:
        if char == 'R':
            false_flag = 1
            break

if false_flag == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
 
int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    map<ll,ll> m;
    ll ans=0;
    m[1+a[0]]++;
    for(int i=1;i<n;i++)
    {
        ans+=m[i+1-a[i]];
        m[i+1+a[i]]++;
    }
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 27968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
int cha[27];
signed main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        cha[s[i]-'A']++;
    }

    int syu=0;
    int nn=0;
    rep(i,27){
        if(cha[i]>0)syu++;
        if(cha[i]==2)nn++;
    }
    if(syu==2&&nn==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    
 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long int;
 
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;
 
template<typename T>
void print(vector<T> a){
	for (auto x:a){
		cout << x << " ";
	}
	cout << endl;
}
 
template<typename T>
void print2d(vector<vector<T>> a){
	for (auto v:a){
		for (auto x:v){
			cout << x << " ";
		}
		cout << endl;
	}
}
 
 
 
int main()
{
	int n;
	cin >> n;
	int cnt = 0;
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		if(a==b)
			cnt++;
		else
			cnt = 0;
		if(cnt > 2){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3620
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

#include "atcoder/all"
using namespace atcoder;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> ft(n);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        ft.add(i, a);
    }
    for(int i = 0; i < q; i++){
        char op; cin >> op;
        int n1, n2;
        cin >> n1 >> n2;
        if(op == '0'){
            ft.add(n1, n2);
        }else{
            cout << ft.sum(n1, n2) << '\n';
        }
    }
}


Measured memory_bytes: 8228
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int k;
	string s;
	cin >> k >> s;
	if(s.length() <= k){
		cout << s << '\n';
	}
	else{
		cout << s.substr(0,k) + "..." << '\n';
	}
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    h[0]--;
    FOR(i,1,n){
      if(h[i-1]==h[i]) continue;
      else if(h[i-1]<h[i]) h[i]--;
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }
    //cout_vec(h);
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M) {
        int u,v; cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
    }
    int S,T; cin >> S >> T;
    S--; T--;

    vector<vector<int>> d(N, vector<int>(3,INF));
    d[S][0] = 0;
    queue<pair<int, int>> que;
    que.emplace(S,0);
    while(!que.empty()) {
        int v,c;
        tie(v,c) = que.front(); que.pop();
        int nc = (c+1) % 3;
        for (auto nv : G[v]) {
            if (d[nv][nc] != INF) continue;
            d[nv][nc] = d[v][c] + 1;
            que.emplace(nv,nc);
        }
    }

    if (d[T][0] == INF) cout << -1 << endl;
    else cout << d[T][0] / 3 << endl;
}


Measured memory_bytes: 11264