akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  long k=0;
  while(k*(k-1)<2*N)k++;
  if(k*(k-1)>2*N){cout<<"No"<<endl;return 0;}
  vector<vector<long>>A(k,vector<long>(k));
  long l=1;
  for(long i=0;i<k;i++)for(long j=i+1;j<k;j++){
    A[i][j]=l;A[j][i]=l;l++;
  }
  vector<vector<long>>S(k);
  for(long i=0;i<k;i++)for(long j=0;j<k;j++)
    if(i!=j)S[i].push_back(A[i][j]);
  cout<<"Yes"<<endl;
  cout<<k<<endl;
  for(long i=0;i<k;i++){
    cout<<S[i].size()<<" ";
    for(long x:S[i])cout<<x<<" ";
    cout<<endl;
  }
}



Measured memory_bytes: 6968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
int v[200000 + 100];
int main () {
  ios::sync_with_stdio(false);
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> v[i];
  ll ret = 0;
  int i = 0;
  int j = 0;
  int t = 0;
  while(i < N) {
    while(j < N && ((v[j] & t) == 0)) {
      t ^= v[j];
      j++;
    }
    ret += j - i;
    t ^= v[i];
    i++;
  }

  cout << ret << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
	char s[3];
	scanf("%s",&s);
	int flag = 0;
	int i;
	for(i=0;i<3;i++){
		if(s[i] =='a'){
			flag +=2;
		}
		if(s[i] =='b'){
			flag +=3;
		}
		if(s[i] =='c'){
			flag +=5;
		}
	}
	if(flag==10){
		printf("Yes");
		return 0;
	}else{
		printf("No");
		return 0;
	}
	return 0;
}	

Measured memory_bytes: 128
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
a = na()
a.sort()

ans = 1
for i in range(n):
    if ans >= 1 and a[i] > 10 ** 18:
        print(-1)
        exit()
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21632
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=500001;
int a[maxn];
int main(){
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  int di=0;
  di=a[2]-a[0];
  di+=a[2]-a[1];
  if(di%2==0)cout<<di/2<<endl;
  else cout<<di/2+2<<endl;
}


Measured memory_bytes: 256
S = input()

S_len = len(S)
if S_len % 2 == 0:
    base = 2
else:
    base = 1

for i in range(base, S_len-1, 2):
    if S[0:(S_len-i)//2] == S[(S_len-i)//2:S_len-i]:
        print(S_len-i)
        break


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

int main() {
    int N;
    cin >> N;
    vector<int> ans(N + 1);
    for (int x = 1; x < 100; x++) {
        for (int y = 1;y < 100; y++) {
            for (int z = 1; z < 100; z++) {
                int temp = x * x + y * y + z * z + x * y + y * z + z * x;
                if (temp <= N)
                {
                    ans[temp]++;
                }
                
            }
        }
    }
    for (int i = 1; i <= N; i++)
    {
        cout << ans[i] << endl;
    }
    
    
  return 0;
}


Measured memory_bytes: 3556
N, K = map(int, input().split())
S = input()
zeros = []
count = 1
if S[0] == "0":
    zeros.append(0)
for i in range(N):
    if i + 1 == N or S[i] != S[i + 1]:
        zeros.append(count)
        count = 1
    elif S[i] == S[i + 1]:
        count += 1
if S[-1] == "0":
    zeros.append(0)
M = len(zeros)
ans = sum(zeros[0:2 * K + 1])
temp = ans
for l in range(2, M - 2 * K, 2):
    temp += zeros[l + 2 * K - 1] + zeros[l + 2 * K] - zeros[l - 2] - zeros[l - 1]
    ans = max(ans, temp)
print(ans)


Measured memory_bytes: 4468
import scala.io.StdIn

object Main extends App {

  final val nil = -1
  
  case class Node(var parent: Int = -1,var left: Int = -1, var right: Int = -1){
    
    def typeInfo: String = if(parent == -1) {
      "root"
    } else if(left == nil && right == nil) {
      "leaf"
    } else {
      "internal node"
    }
    
    def nodeLiteral(depth: Int, sibling: Int, height: Int): String = {
      val degree = (if(left == nil) 0 else 1) + (if(right == nil) 0 else 1)
      s"parent = $parent, sibling = $sibling, degree = $degree, depth = $depth, height = $height, $typeInfo"
    }
    override def toString: String = s"parent = $parent, depth = X, $typeInfo, [child]"
    
  }

  def setDepth(index: Int, cnt: Int): Unit = {
    //println("setDepth:" + index)
    depth(index) = cnt
    if(input(index).right != nil){ 
      setDepth(input(index).right, cnt + 1)
    }
    if(input(index).left != nil){ 
      setDepth(input(index).left, cnt + 1)
    }
  }
  
  def setHeight(index: Int): Int = {
    //println("setDepth:" + index)
    val h1 = if(input(index).right != nil){
      setHeight(input(index).right) + 1
    } else 0
    val h2 = if(input(index).left != nil){
      setHeight(input(index).left) + 1
    } else 0
    height(index) = scala.math.max(h1, h2)
    height(index)
  }
  
  def getChild(index: Int): Array[Int] = (input(index).left, input(index).right) match {
    case (-1,      -1) => Array.empty[Int]
    case (left,    -1) => Array(left)
    case (-1,   right) => Array(right)
    case (left, right) => Array(left, right)
  }
  
  val n = StdIn.readLine().trim.toInt
  val input  = Array.fill[Node](n)(Node())
  val depth  = Array.fill[Int](n)(0)
  val height = Array.fill[Int](n)(0)

  (0 until n).foreach{ _ =>
    val Array(current, left, right) = StdIn.readLine().trim.split(" ").map(_.toInt)
    input(current).left = left
    input(current).right = right
    if(left != nil) input(left).parent = current
    if(right != nil) input(right).parent = current
  }

  var root = nil
  (0 until n).foreach{ i =>
    //println(s"$i:" + input(i))
    if(input(i).parent == nil) root = i
  }
  
  setDepth(root, 0)
  setHeight(root)
  
  (0 until n).foreach{ i =>
    val ch = getChild(i)
    val parent = input(i).parent
    val sibling = if(parent != nil){
      if(input(parent).left == i) input(parent).right
      else input(parent).left
    } else -1
    
    println(s"node $i: " + input(i).nodeLiteral(depth(i), sibling, height(i)))
  }

}


Measured memory_bytes: 44424
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int r[200001]={0},d[200001]={0};
ll c[200001]={0};
vector<int> A[200001];
int search(int x,ll y){
  if(r[x]) return 0;
  r[x]=1;
  d[x]=y;
  for(auto i:A[x]) search(i,y+c[i]);
}
int main(){
    int n,q,a,b;
    ll p,x;
    cin>>n>>q;
    rep(i,n-1) cin>>a>>b,A[a].push_back(b),A[b].push_back(a);
    rep(i,q) cin>>p>>x,c[p]+=x;
    search(1,c[1]);
    rep(i,n) cout<<d[i+1]<<" ";
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n+1);
  rep(i, n) cin >> a[i+1];
  vector<int> b(n+1);
  for(int i = n; i >= 1; --i) {
    int sum = 0;
    for(int j = i+i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum ^ a[i];
  }
  vector<int> ans;
  for(int i = 1; i <= n; i++) {
    if(b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep(i, ans.size()) {
    if(i) cout << " ";
    cout << ans[i];
    if(i == ans.size()-1) cout << endl;
  }

  return 0;
}


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

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;;
using ll = long long;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	bool ans = true;
	if (A != B && B != C && A != C) {
		ans = false;
	}
	else if (A == B && B == C && A == C) {
		ans = false;
	}
	puts(ans ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

a, b, k = map(int, input().split())

x = y = 0
if a < k: x = 0
elif k < a:
    print(a - k, b)
    exit(0)
else: x = k - a

k -= a
if b < k: y = 0
else: y = b - k

print(x, y)


Measured memory_bytes: 9132
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_end().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<u8> = read_vec();
    for i in 0..v.len() {
        if v[i] == 0 {
            println!("{}", i + 1);
        }
    }
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    if(S=="SUN")
        cout<<"7";
    if(S=="MON")
        cout<<"6";
    if(S=="TUE")
        cout<<"5";
    if(S=="WED")
        cout<<"4";
    if(S=="THU")
        cout<<"3";
    if(S=="FRI")
        cout<<"2";
    if(S=="SAT")
        cout<<"1";
    return 0;}
    
    
    
    
    
    
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String ans = "No";
		if ((a < c && c < b) || (b < c && c < a)) {
			ans = "Yes";
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, Q, a, b, p, x;

long long A[222222], B[222222];

std::vector<std::vector<int>> G;

bool visit[222222];


void dfs(int i, long long s)
{
  visit[i] = true;

  B[i] = s += A[i];

  for (const auto& k : G[i]) {
    if (visit[k])
      continue;

    dfs(k, s);
  }
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N >> Q;
  
  G.resize(N + 1);

  for (int i = 0; i < N - 1; i ++) {
    std::cin >> a >> b;

    G[a].push_back(b);
    G[b].push_back(a);
  }

  memset(A, 0, sizeof(A));
  memset(B, 0, sizeof(B));

  for (int i = 0; i < Q; i ++) {
    std::cin >> p >> x;

    A[p] += x;
  }

  memset(visit, 0, sizeof(visit));

  dfs(1, 0);

  for (int i = 1; i <= N; i ++)
    std::cout << B[i] << ' ';
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 23296
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003

int dp[353][353]={0};
int bow[353][353]={0};


int main(){
	
	int n;
	cin>>n;
	while(n--){
		int x=0,y=0;
		int a,b;
		int xa=0,ya=0;
		double ans=0;
		while(cin>>a>>b,a!=0||b!=0){
			x+=a;
			y+=b;
			if(ans<sqrt(x*x+y*y)){
				xa=x;
				ya=y;
				ans=sqrt(x*x+y*y);
			}
			else if(ans==sqrt(x*x+y*y)){
				if(x>xa){
					xa=x;
					ya=y;
				}
			}
				
		}
		cout<<xa<<" "<<ya<<endl;
	}
	
	
	

	
}

Measured memory_bytes: 1160
n=int(input())
a = list(map(int,input().split()))
x0,x1,x2,o0,o1,o2=a[0],-10**18,0,-10**18,a[1],-10**18
for i in a[2:]:
  x0,x1,x2,o0,o1,o2=o0,max(o1,x0),max(o2,x1),x0+i,x1+i,x2+i
print(max(x0,x1,o1)if n%2==0 else max(x1,x2,o2))

Measured memory_bytes: 31024
#include <bits/stdc++.h>
 
using namespace std;
int r;
string t , s;
int mn = 1e9;
int main()
{
     
    cin >> t >>s;
    int szt = t.size();
    int szs = s.size();
    
    for ( int j = 0 ; j < szt ; j++ )
    {
         int x = j;
         r=0;
     if ( szt - x >= szs )
       {   for ( int z = 0; z <szs ; z++ )
          {
             if ( t[x] != s[z] )
              r++;
          x++;   
         } 
        //  cout << r<< endl;  
          mn = min ( mn , r );
        }}

    
      cout << mn;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  ll k;
  cin >> s >> k;

  for (int i = 0; i < k; i++) if (s[i] != '1') {
    cout << s[i] << endl;
    return 0;
  }

  // 解答
  cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  string s; cin >> s;
  int ans = 1e9;
  for(int i=0; i<s.size()-2; i++){
    int a = 100 * (s[i]-'0') + 10 * (s[i+1]-'0') + (s[i+2]-'0');
    ans = min(abs(753-a), ans);
  }
  cout << ans << endl;


  return 0;
}




///


Measured memory_bytes: 256
/****************************************

			LostMartian

****************************************/
//#pragma GCC optimize("Ofast")  
//#pragma GCC target("avx,avx2,fma") 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	pn(args...); 
}
template <typename Arg1>
void ps(Arg1&& arg1) { 
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	ps(args...); 
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1; 
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { 
	cin >> arg1; 
	read(args...); 
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define umap unordered_map<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define test ll t; cin>>t; while(t--)
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define iAmSpeed ios_base::sync_with_stdio(false); cin.tie(NULL);
void LOCAL();
int main()
{
	clock_t z = clock();
	//LOCAL();
	iAmSpeed
	
	string S, T;
    cin >> S >> T;

    ll SZ_S = S.size(), SZ_T = T.size(), MinDifference = INT_MAX;
    string ans;

    for (ll i = 0; i + SZ_T <= SZ_S; i++) {
        ll CurrentDifference = 0;       
        for (ll j = 0; j < SZ_T; j++) {      
            if (S[i + j] != T[j])
                CurrentDifference++;
        }
        if (CurrentDifference < MinDifference) {
            ans = S.substr (i, SZ_T);
            MinDifference = CurrentDifference;
        }
    }

    ll k=0;
    rep(i,0,ans.length()) {
    	if(T[i]!=ans[i]) {
    		k++;
    	}
    }
    cout << k << endl;













	debug("Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}
void LOCAL() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}


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

using namespace std;
string s;
int main(){
	cin >> s;
	int i,n = s.size(),cnt = 0;
	string t,u;
	for(i=0;i<n;i++){
		if(t.size()==0){
			cnt++; t.push_back(s[i]);
		}else{
			u.push_back(s[i]);
			if(t!=u){
				cnt++;
				t = u; u.clear();
			}
		}
	}
	cout << cnt << endl;
}
	

Measured memory_bytes: 640
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 3005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,dp[MAXN][MAXN],sum[MAXN];
char str[MAXN+1];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
int main()
{
    scanf("%d",&n);
    scanf("%s",str+2);
    str[1]='<';
    dp[0][n]=1;
    for(int i=1;i<=n;i++)
    {
        memset(sum,0,sizeof(sum));
        sum[0]=dp[i-1][0];
        for(int j=1;j<=n;j++) 
        {
            sum[j]=sum[j-1];
            add(sum[j],dp[i-1][j]);
        }
        for(int j=0;j<=n-i;j++)
        {
            if(str[i]=='<') dp[i][j]=(sum[n]-sum[j]+MOD)%MOD;
            else dp[i][j]=sum[j];
        }
    }
    printf("%d\n",dp[n][0]);
    return 0;
}



Measured memory_bytes: 35200
N = int(input())
Monsters = [int(i) for i in input().split()]
Heroes = [int(i) for i in input().split()]
res = 0
for i in range(N):
    r = Monsters[i] - Heroes[i]
    if r >= 0:
        Monsters[i] -= Heroes[i]
        res += Heroes[i]
    else:
        res += Monsters[i]
        Monsters[i] = 0
        k = Monsters[i+1] + r
        if k >= 0:
            res -= r
            Monsters[i+1] += r
        else:
            res += Monsters[i+1]
            Monsters[i+1] = 0

print(res)

Measured memory_bytes: 18624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1LL<<60
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << (((b - a - 1) % 2 == 1) ? "Alice" : "Borys") << endl;
	return 0;
}

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

using namespace std;

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

  int count = 0;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r; ++j) {
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
signed main() {
	int l;
	cin >> l;
	printf("%.12lf\n", (double)l * l * l / 27);
	return 0;
}

Measured memory_bytes: 888
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10;
char s[N];
int n , dep[2][N] , maxdep[N];
vi g[N];

void dfs(int c,int fa,int &id,int*dep) {
  dep[c] = fa ? dep[fa] + 1 : 0;
  if(dep[c] > dep[id]) id = c;
  for(auto t : g[c]) if(t != fa)
    dfs(t , c , id , dep);
}

int low[N] , high[N] , dis[N];
ll ans;

void dfs(int c,int fa){
  dis[c] = 0;
  for(auto t : g[c]) if(t != fa) {
    dfs(t , c);
    dis[c] = max(dis[c] , dis[t] + 1);
  }
  if(s[c] == '1') low[c] = 0;
  if(fa == 0) ans += max(0 , maxdep[c] - low[c] + 1);
  else {
    high[c] = dis[c] + 1;
    if(maxdep[c] == maxdep[fa]) {
      high[c] = dis[c];
      low[fa] = min(low[fa] , max(low[c] , high[c] + 1));
      ans += max(0 , high[c] - low[c] + 1);
    } else {
      low[fa] = min(low[fa] , max(low[c] - 1 , high[c]));
      ans += max(0 , high[c] - low[c] + 1);
    }
  }
}

int main(){
  scanf("%d",&n);
  rep(i,1,n) {
    int u,v;
    scanf("%d%d",&u,&v);
    g[u].pb(v);
    g[v].pb(u);
  }
  scanf("%s",s+1);
  int u=0,v=0,w=0;
  dfs(1,0,u,dep[0]);
  dfs(u,0,v,dep[0]);
  dfs(v,0,w,dep[1]);
  rep(i,1,n+1) maxdep[i]=max(dep[0][i],dep[1][i]);
  rep(i,1,n+1) low[i]=1<<30;
  int rt = min_element(maxdep+1,maxdep+1+n)-maxdep;
  dfs(rt,0);
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 28544
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+10;
int n,m,v,p;
int a[maxn];
bool check(int x)
{
	if(x<p)
		return true;
	int sum=0;
	int need=x-p+1;
	for(int i=x-1;i>=0;i--)
	{
		if(need==0)
			break;
		int c=a[i]-a[x];
		if(c>m)
			return false;
		sum+=c;
		--need;
	}
	return sum<=(n-v)*m;
}
signed main()
{
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	sort(a,a+n);
	reverse(a,a+n);
	int l=0,r=n-1;
	while(l<r)
	{
		int mid=(l+r+1)>>1;
		if(check(mid))
			l=mid;
		else
			r=mid-1;
	}
	printf("%d\n",l+1);
	return 0;
}

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

using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }
    else if (A >= 6)
    {
        cout << B/2 << endl;
    }
    else
    {
         cout << 0 << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string W[105];

int main()
{
	int N;
	cin >> N;
	string s = "Yes";
	REP(i, N)
	{
		cin >> W[i];
	}
	FOR(i, N, 1)
	{
		if (W[i][0] != W[i - 1][W[i - 1].length() - 1])
		{
			s = "No";
			break;
		}
	}
	sort(W, W + N);
		FOR(i, N, 1)
	{
		if (W[i] == W[i - 1])
		{
			s = "No";
			break;
		}
	}
	cout << s << endl;
	return 0;
}

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

int main(){
  int n,m;
  int h[200],r[200],dp[200];

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> h[i] >> r[i];

    cin >> m;
    for(int i=n;i<n+m;i++)cin >> h[i] >> r[i];

    for(int i=0;i<n+m;i++)
      for(int j=i+1;j<n+m;j++)
	if(h[i]>h[j] || (h[i]==h[j] && r[i]>r[j])){
	  swap(h[i],h[j]);
	  swap(r[i],r[j]);
	}
   
    int ans = 0;
    for(int i=1;i<n+m;i++)dp[i] = 1;
    dp[0] = 1;
    for(int i=1;i<n+m;i++){
      for(int j=0;j<i;j++)
	if(h[i]>h[j] && r[i]>r[j])dp[i] = max(dp[i],dp[j]+1);
      ans = max(ans,dp[i]);
    }
    
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
N, K = map(int, input().split())
D = list(map(str, input().split()))

for i in range(N, 100000):
    j = str(i)
    more = False
    for k in D:
        if j.count(k) > 0:
            more = True
            break
    if not more:
        ans = i
        break

print(ans)

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

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

    string s;
    cin >> s;
    string res = "Good";
    for (int i = 1; i < 4; i++) {
        if (s[i-1] == s[i]) res = "Bad";
    }
    cout << res << endl;
}



Measured memory_bytes: 256
def abc144b():
    n = int(input())

    start = 1
    end = 9
    flag = False

    # シンプルな全探索
    for i in range(start, end + 1):
        for j in range(start, end + 1):
            if n == i * j:
                flag = True
                break

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

if __name__ == '__main__':
    abc144b()

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

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int d;
  while(cin>>d,d){
    Int n,m;
    cin>>n>>m;
    vector<Int> a(n,0),b(m);
    for(Int i=1;i<n;i++) cin>>a[i];
    for(Int i=0;i<m;i++) cin>>b[i];

    for(Int i=0;i<n;i++) a.emplace_back(a[i]+d);
    sort(a.begin(),a.end());

    Int ans=0;
    for(Int i=0;i<m;i++){
      Int tmp=d;
      {
	auto latte=upper_bound(a.begin(),a.end(),b[i]);
	if(latte!=a.end()) chmin(tmp,abs(*latte-b[i]));
	if(latte!=a.begin()) --latte;
	if(latte!=a.end()) chmin(tmp,abs(*latte-b[i]));
      }
      {
	b[i]+=d;
	auto latte=upper_bound(a.begin(),a.end(),b[i]);
	if(latte!=a.end()) chmin(tmp,abs(*latte-b[i]));
	if(latte!=a.begin()) --latte;
	if(latte!=a.end()) chmin(tmp,abs(*latte-b[i]));
      }
      ans+=tmp;
    }

    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll x, y, z;
        in >> x >> y >> z;
        ll ans = 1;
        while (true) {
            if (y * ans + z * (ans + 1) > x) {
                break;
            }
            ans++;
        }
        ans--;
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

S = readline().rstrip().replace("BC","X")

# AAXXX のようにAとXだけで構成されている部分は、
# Xを全て左に移動する
# BとCが残っている部分で切れる

parts = S.replace("B",",").replace("C",",").split(",")

ans = 0
for part in parts:
  # Xを探し、Xにあったら、そのときのインデックス - それまでにXを見つけた数する
  cnt = 0
  for i in range(len(part)):
    if part[i] == "X":
      ans += (i - cnt)
      cnt += 1

print(ans)

Measured memory_bytes: 5668
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 998244353;

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

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int H, W, N, sr, sc;
string S, T;

bool judge(char A){
  char B;
  if(A == 'L') B = 'R';
  else if(A == 'R') B = 'L';
  else if(A == 'U') B = 'D';
  else B = 'U';

  int nokori;
  if(A == 'U') nokori = sr;
  else if(A == 'D') nokori = H+1-sr;
  else if(A == 'L') nokori = sc;
  else nokori = W+1-sc;

  int limit;
  if(A == 'L' or A == 'R') limit = W;
  else limit = H;

  REP(i, N){
    if(S[i] == A) nokori--;
    if(nokori <= 0) return 0;
    if(T[i] == B) nokori = min(limit, nokori+1);
  }
  return 1;
}

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

  cin >> H >> W >> N >> sr >> sc >> S >> T;
  bool ans = (judge('U') and judge('D') and judge('L') and judge('R'));
  cout << (ans ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 920
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long idx = 0;
		for (int i = 1; i < n; i++) {
		    idx += idx / (k - 1) + 1;
		}
		System.out.println(idx);
	}
}



Measured memory_bytes: 26300
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define SHOW(a) cout << #a << " = " << a << endl;

void solve(){
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N * A, B) << endl;
}

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

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

int main()
{
	cout << fixed << setprecision(10);
	int n, m, d;
	cin >> n >> m >> d;
	if (d == 0) {
		int x = n;
		cout << (((ld)x / n) / n) * (m - 1) << endl;
		return 0;
	}
	int x = max(0, n * 2 - d * 2);
	cout << (((ld)x / n) / n) * (m - 1) << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, m int
	fmt.Scan(&N)
	w := N
	for w > 1 {
		m += w % 10
		w = w / 10
	}
	m += w % 10
	if N%m == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

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

int main() {
	int A, B, X;
  	cin >> A >> B >> X;
  
  	bool can = true;
  
  	if(A > X) can = false;
  
 	if(A + B < X) can = false;
  
  	if(can) {
      cout << "YES" << endl;
    }else {
      cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H , W;
  cin >> H >> W;
  vector<char>F(W+2,'#');
  for(int i = 0;i < W+2;i++){
    cout << F.at(i) ;
}
  cout << endl;
  vector<char>P(W);
  for(int j = 0; j < H;j++){
    cout << '#' ;
    for(int l = 0; l < W ;l++){
      cin >> P.at(l) ;
      cout << P.at(l);
    }
    cout << '#' <<endl;
  }
  for(int k = 0;k < W+2;k++){
    cout << F.at(k) ;
}
}
  
  

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

using namespace std;

int solve(){
    vector<int> v(5);
    int res;
    for (int i = 0; i < 5; i++)
    {
        cin>>v[i];
        if(v[i]==0) res=i+1;
    }

    cout<<res;
    
    return 0;
}

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


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> num(B);
  for(int i = 1; i <= 100; i++){
    num[A%B]++;
    A = A*(i + 1)/i;
  }
  if(num[C] > 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        int[] A = new int[3];
        Scanner scan = new Scanner(System.in);
        A[0] = Integer.parseInt(scan.next());
        A[1] = Integer.parseInt(scan.next());
        A[2] = Integer.parseInt(scan.next());

        int tmpmin = 101;
        int nummin=0;
        int tmpmax = 0;
        int nummax=0;
        int num=0;
        for(int i = 0;i<3;i++){
            if(tmpmin>=A[i]){
                tmpmin = A[i];
                nummin = i;
            }
            if(tmpmax<A[i]){
                tmpmax=A[i];
                nummax = i;
            }
            if(i!=nummin && i !=nummax){
                num = i;
            }
        }
        int cost = 0;
        cost += A[num]-A[nummin];
        cost+= A[nummax]-A[num];
        System.out.println(cost);
    }
}

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

int main()
{
  char c[4];
  scanf("%s", &c);
  if(c[0] == c[1] && c[1] == c[2] ||
     c[1] == c[2] && c[2] == c[3])
  {
    puts("Yes");
  }
  else
  {
    puts("No");
  }
}

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

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

  vector<int> vec_l(N);
  vector<int> vec_r(N);
  for(int i=0;i<N;i++){
    cin >> vec_l.at(i) >> vec_r.at(i);
  }

  int count = 0;
  for(int i=0;i<N;i++){
    count += vec_r.at(i) - vec_l.at(i) + 1;
  }

  cout << count << endl;
}


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  n <<= 1;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a.begin() + 1, a.end());
  vector<int> f(n + 1);
  for (int i = 2; i <= n; ++i) {
    f[i] = max(f[i - 1], f[i - 2] + a[i - 1]);
  }
  cout << *max_element(f.begin() + 1, f.end()) << '\n';
  return 0;
}


Measured memory_bytes: 256
struct Scanner {
    private var elements = [String]()
    private var index = 0

    mutating func peek() -> String {
        while elements.count == index {
            elements = readLine()!.split(separator: " ").map(String.init)
            index = 0
        }
        return elements[index]
    }

    mutating func next() -> String {
        let value = peek()
        index += 1
        return value
    }

    mutating func nextInt() -> Int {
        return Int(next())!
    }

    mutating func nextDouble() -> Double {
        return Double(next())!
    }
}

var scanner = Scanner()
let N = scanner.nextInt()
let L = (0 ..< N).map { _ in scanner.nextInt() }.sorted()

var answer = 0
for i in 0 ..< N {
    for j in i + 1 ..< N {
        for k in j + 1 ..< N {
            guard L[i] != L[j] && L[i] != L[k] && L[j] != L[k] else { continue }
            if L[i] + L[j] > L[k] {
                answer += 1
            }
        }
    }
}
print(answer)


Measured memory_bytes: 8104
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,d,a;
    cin>>n>>d>>a;
    vector<P> x_h(n+1);
    FOR(i,0,n){
        cin>>x_h[i].first>>x_h[i].second;
        x_h[i].second = (x_h[i].second+a-1)/a;
    }
    x_h[n] = P(1e12, 0);
    sortAl(x_h);
    ll ans = 0;
    ll l = 0;
    vector<ll> res(n);
    ll tmp = 0;
    FOR(i,0,n){
        while(x_h[l].first < x_h[i].first - 2*d){
            tmp -= res[l];
            l++;
        }
        ll dmg = max(x_h[i].second - tmp, (ll)0);
        res[i] = dmg;
        tmp += dmg;
        ans += dmg;
    }
    cout<<ans<<endl;

}

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

const ll MOD = 1000000007;
const ll INF = 9999999999;

int main() {
  int N; ll W; cin >>N >>W;
  vector<ll> weight(N),value(N);
  rep (i,N) cin >>weight.at(i) >>value.at(i);

  vector<vector<ll>> dp(N+2, vector<ll>(100100, 0));
  // dp[i][j]...i-1番目までの品物から重さがj以下となるように選んだ時の勝ちの総和の
  // 最大値
  for (int i=0; i<N; i++){
    for (int j=0; j<=W; j++){
      if (j >= weight[i]) chmax(dp[i+1][j], dp[i][j-weight[i]] + value[i]);
      chmax(dp[i+1][j], dp[i][j]);
    }
  }
  cout <<dp[N][W] <<endl;
  
}

Measured memory_bytes: 81024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
bool bs[55], vis[55];
int A[55], B[55], maxi;

bool check() {
	// check if all A[i] are reachable to B[i] for every i without using number m
	for (int i = 0; i < N; ++i) {
		queue<int> q;
		memset(vis, 0, sizeof(vis));
		q.push(A[i]);
		vis[A[i]] = true;
		bool flag = false;
		while (!q.empty()) {
			int u = q.front();
			q.pop();
			for (int j = 1; j <= A[i]; ++j) {
				if (!bs[j]) continue;
				int v = u % j;
				if (vis[v]) continue;
				vis[v] = true;
				// visit v is on
				if (v == B[i]) {
					flag = true;
					goto L;
				}
				if (v != 0) q.push(v);

			}
		}
	L:
		if (!vis[B[i]]) return false;
	}
	return true;
}


int main()
{
	int i, j, k, x;
	scanf("%d", &N);
	for (i = 0; i < N; ++i) {
		scanf("%d", &A[i]);
	}

	for (i = 0; i < N; ++i) {
		scanf("%d", &B[i]);
	}
	for (i = 1; i <= 50; ++i) bs[i] = true;
	for (i = 0; i < N; ++i) {
		if (A[i] != B[i]) break;
	}
	if (i == N) {
		printf("0");
		return 0;
	}
	if (!check()) {
		printf("-1");
		return 0;
	}
	ll sum = 0LL;
	for (i = 50; i >= 1; --i) {
		bs[i] = false;
		if (!check()) {
			bs[i] = true;
			sum += (1LL << i);
		}
	}
	printf("%lld", sum);
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.rbegin(), a.rend());
  cout << (a[m - 1] < (sum + 4 * m - 1) / (4 * m) ? "No" : "Yes") << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
const int MOD=1000000007;
int h,w;
char a[1010][1010];
ll dp[1010][1010];
int main(){
  scan(h);scan(w);
  rep1(i,h){
    rep1(j,w){
      scan(a[i][j]);
    }
  }
  memset(dp,0,sizeof(dp));
  dp[0][1]=1;
  rep1(i,h){
    rep1(j,w){
      if(a[i][j]=='#'){
	dp[i][j]=0;
      }
      else{
	dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
      }
    }
  }
  prin(dp[h][w]);
  /*  rep1(i,h){
    rep1(j,w){
      cout<<dp[i][j];
    }
    cout<<"\n";
    }*/

  

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a = N/100;
  int b = (N%100)/10;
  int c = N%10;
  if (a == 7 || b == 7 || c == 7) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

int main(void) 
{
	int k;
	int i;
	int sum, record;

	while (scanf("%d", &k), k != 0) {
		sum = 0;
		
		for (i = 0; i < (k * (k - 1) / 2); i++) {
			scanf(" %d", &record);
			sum += record;
		}
		printf("%d\n", sum / (k - 1));
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<bool> vecbool;
typedef vector<vector<int>> vec2int;
typedef pair<int, int> P;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, m;
  cin >> n >> m;
  vecint h(n);
  for (auto& e : h) cin >> e;
  vec2int G(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  REP(i, n) {
    bool ok = true;
    for (auto& e : G[i]) {
      if (h[i] <= h[e]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8752
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
int main(){
	int N,M,a,b;
	int C[200005]={};
	bool k=false;
	cin>>N>>M;
	for(int i=0;i<M;++i){
		cin>>a>>b;
		if(a==1)C[b]++;
		if(b==N)C[a]++;
		if(C[a]>=2)k=true;
		if(C[b]>=2)k=true;
	}
	if(k){
		cout<<"POSSIBLE"<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
x, y, t = (0, 0, 0)
f = True
for i in range(N) :
    nt, nx, ny = list(map(int, input().split()))
    dist = abs(nx - x) + abs(ny - y)
    if dist > nt - t or (nx+ny+nt-t)%2 != (x+y)%2 :
        f = False
print("Yes" if f else "No")

Measured memory_bytes: 3060
s=raw_input()
a,b,c=0,0,0
for ch in s :
    if ch=='a' :
        a+=1
    elif ch=='b' :
        b+=1
    else :
        c+=1

if max(a,b,c)<=min(a,b,c)+1 :
    print "YES"
else :
    print "NO"


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

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

    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
}

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

const int mod=998244353;

int n,k;
int l[15],r[15];
int bit[200005];

int sum(int pos){
    int res=0;
    while(pos>0){
        res=(res+bit[pos])%mod;
        pos-=pos&-pos;
    }
    return res;
}

void add(int pos,int val){
    while(pos<=n){
        bit[pos]=(bit[pos]+val)%mod;
        pos+=pos&-pos;
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for(int i=1;i<=k;i++){
        cin>>l[i]>>r[i];
    }
    add(1,1);
    add(2,mod-1);
    for(int i=1;i<n;i++){
        int cur=sum(i);
        for(int j=1;j<=k;j++){
            add(i+l[j],cur);
            add(i+r[j]+1,mod-cur);
        }
        cerr<<sum(i)<<endl;
    }
    cout<<sum(n)<<endl;

    return 0;
}

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

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

  string ans = "No";
  for (int i = 1; i < 10; i++){
    for (int j = 1; j < 10; j++){
      if (N == i*j) ans = "Yes";
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    vector<int> num_a(100001, 0);
    for (int i = 0; i < n; i++) {
        num_a.at(a.at(i))++;
    }
    int ans = 1;
    for (int i = 0; i < n; i++) {
        int count = 0;
        if (i-1 >= 0) {
            for (int j = -1; j <= 1; j++) {
                count += num_a.at(i+j);
            }
        } else {
            for (int j = 0; j <= 1; j++) {
                count += num_a.at(i+j);
            }
        }
        ans = max (ans, count);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024