akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			System.out.print(a[n-1]);
			for(int i = n-2; i >= 0; i--) {
				System.out.print(" "+ a[i]);
			}
			System.out.println();
		}
	}

}



Measured memory_bytes: 26544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ll n; cin >> n;
    ll ans = 0;
    ans = n*(n-1)/2;
    if(n==1) cout << 0 << endl;
    else if(n==2) cout << 1 << endl;
    else {
        cout << ans << endl;
    }

    return 0;
}

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


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

int main() {
  string S;
  cin >> S;
  int pow10mod[200005];
  int nums[200005];
  int nummod2019[200005];
  map<int, int> counts;
  nums[0] = 1;
  pow10mod[0] = 1;
  nummod2019[0] = 0;
  counts[0]++;
  for(int i=1; i<=S.size(); i++) {
    // numsのi桁目は入力のi桁目
    nums[i] = S[S.size()-i] - '0';
  }
  for(int i=1; i<=S.size(); i++) {
    // pow10modのi桁目は10^iのmod 2019
    // pow10mod[0] = 1
    pow10mod[i] = pow10mod[i-1] * 10 % 2019;
  }
  for(int i=1; i<=S.size(); i++) {
    // nummod2019のi桁目はSのi桁目までのmod 2019
    // nummod2019[0] = 0
    nummod2019[i] = (nummod2019[i-1] + pow10mod[i-1] * nums[i]) % 2019;
    counts[nummod2019[i]]++;
  }
  int modcount;
  int ans = 0;
  rep(i, 2019) {
    modcount = counts[i];
    ans += modcount * (modcount - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6024
import sys
fastinput = sys.stdin.readline
N,D,A = [int(i) for i in fastinput().split()]
preXH = [[int(i) for i in fastinput().split()] for j in range(N)]
preXH.sort()
XH = [[x,h//A + bool(h%A)] for x,h in preXH]
X = [x for x,h in XH]+[100000000000000000]
Diff = [X[m+1]-X[m] for m in range(N)]
reach = []
count = 0
l = X[0]
r = X[0]+2*D
for m in range(1,N+1):
    while r<X[m]:#l一個すすめる
        reach.append(m-1)
        r += Diff[count]
        count += 1

damage = 0
ans = 0
DIFF = [0]*N#ダメイジのdiff
for n,d in enumerate(DIFF):
    damage += d
    if damage<XH[n][1]:#殺しきれてない
        bonu = XH[n][1]-damage
        damage += bonu
        ans += bonu
        if reach[n]<N-1:DIFF[reach[n]+1] -= bonu
print(ans)

Measured memory_bytes: 116328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong
const double PI=3.14159265358979323846;
int dp[100010][3]; //dp[i][j] i-1日目にjを選択

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;
}

struct input{
    int a;
    int b;
    int c;
};

int main(){
    int n;
    cin >> n;
    vector<vector<int>> x(n,vector<int>(3));
    for(int i=0;i<n;i++){
        cin >> x[i][0] >> x[i][1] >> x[i][2];
    }
    for(int i=0;i<100010;i++){
        for(int j=0;j<3;j++){
            dp[i][j] = -1;
        }
    }
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j != k){
                    chmax(dp[i+1][k],dp[i][j] + x[i][k]);
                }
            }
        }
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;

}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, M;
  cin >> N >> M;

  auto ok = [N,M](const LL d){
    LL num = M / d;
    return N <= num;
  };

  LL ans = 1;
  for(LL i=1;i*i<=M;++i){
    if(M % i) continue;
    if(ok(i)) maxi(ans, i);
    if(ok(M/i)) maxi(ans, M/i);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
h,w=gets.split.map(&:to_i)
map=[]
h.times{map.push(gets.chomp.split(//))}
d=[[0,1],[1,1],[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1]]
map.each_with_index do |row,i|
    row.each_with_index do |col,j|
        map[i][j]=0 if col=='.'
        if col=='.'
            d.each do |dy,dx|
                if i+dy>=0 and j+dx>=0 and i+dy<h and j+dx<w
                    map[i][j]+=1 if map[i+dy][j+dx]=='#'
                end
            end
        end
    end
end

map.each do |row|
    puts row.join
end

Measured memory_bytes: 2172
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    ll sum = 0;
    for(ll a : A){
        sum += a;
    }

    ll one_time = (N+1)*N/2;
    if(sum % one_time != 0){
        p_no();
        return 0;
    }
    else{
        vector<ll> B(N);
        FOR(i, 0, N-1){
            B[i] = A[i+1] - A[i];
        }
        B[N-1] = A[0] - A[N-1];

        ll k = sum / one_time;
        
        FOR(i, 0, N){
            B[i] -= k;
        }
        
        // check
        FOR(i, 0, N){
            if(B[i] <= 0 && B[i]%N==0){

            }else{
                p_no();
                return 0;
            }
        }
    }

    p_yes();
    
    return 0;
}

Measured memory_bytes: 1792
#

import sys
input=sys.stdin.readline

def main():
    N,K=map(int,input().split())
    A=[0]+list(map(int,input().split()))
    for i in range(K+1,N+1):
        if A[i]>A[i-K]:
            print("Yes")
        else:
            print("No")
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 31612
# Solution using a lazy segment tree

from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


class SegmentTree:  # 0-indexed
    def __init__(self, array, operation=min, identity=10**30):
        self.identity = identity
        self.n = len(array)
        self.N = 1 << (self.n - 1).bit_length()
        self.tree = [self.identity] * 2 * self.N
        self.lazy = [None] * 2 * self.N
        self.opr = operation
        for i in range(self.n):
            self.tree[i+self.N-1] = array[i]
        for i in range(self.N-2, -1, -1):
            self.tree[i] = self.opr(self.tree[2*i+1], self.tree[2*i+2])

    def values(self):
        return self.tree[self.N-1:self.n+self.N-1]

    def getindex(self, l, r):
        l = (l + self.N)
        r = (r + self.N)
        lm = l // (l & -l) >> 1
        rm = r // (r & -r) >> 1
        while r-l > 0:
            if r <= rm:
                yield r
            if l <= lm:
                yield l
            l = l >> 1
            r = r >> 1
        while l:
            yield l
            l = l >> 1

    def propagates(self, *indices):
        for i in reversed(indices):
            i -= 1
            v = self.lazy[i]
            if v is None:
                continue
            self.lazy[2*i+1] = self.tree[2*i+1] = v >> 1
            self.lazy[2*i+2] = self.tree[2*i+2] = v >> 1
            self.lazy[i] = None

    def update(self, p, q, x):
        if p == q:
            return None
        indices = tuple(self.getindex(p, q))
        self.propagates(*indices)
        p += self.N-1
        q += self.N-2
        while q-p > 0:
            if p % 2 == 0:
                self.lazy[p] = self.tree[p] = x
            if q % 2 == 1:
                self.lazy[q] = self.tree[q] = x
            p = p//2
            q = q//2 - 1
            x <<= 1
        if p == q:
            self.lazy[p] = self.tree[p] = x
        for i in indices:
            i -= 1
            self.tree[i] = self.opr(self.tree[2*i+1], self.tree[2*i+2])

    def query(self, p, q):  # [p,q)
        if q <= p:
            print("Oops!  That was no valid number.  Try again...")
            exit()
        self.propagates(*self.getindex(p, q))
        p += self.N-1
        q += self.N-2
        res = self.identity
        while q-p > 0:
            if p % 2 == 0:
                res = self.opr(res, self.tree[p])
            if q % 2 == 1:
                res = self.opr(res, self.tree[q])
            p = p//2
            q = q//2 - 1
        if p == q:
            res = self.opr(res, self.tree[p])
        return res


n, q = map(int, input().split())

Works = []
for _ in range(n):
    s, t, x = map(int, input().split())
    Works.append((s, t, x))
Works = sorted(Works, key=lambda w: -w[2])

People = []
for _ in range(q):
    People.append(int(input()))

ST = SegmentTree([-1]*q)

for s, t, x in Works:
    left = bisect_left(People, s-x)
    right = bisect_left(People, t-x)
    ST.update(left, right, x)

for i in range(q):
    print(ST.query(i, i+1))


Measured memory_bytes: 160144
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


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

    if(s.back() == 's'){
        s.push_back('e');
        s.push_back('s');
    }
    else{
        s.push_back('s');
    }

    cout << s << endl;
    return 0;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {


		var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			//答えの出力
			var ans = N*N;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}



Measured memory_bytes: 28120
#include <bits/stdc++.h>
#define MAX (ll)(2e5 + 1)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	string st;
	cin >> st;
	reverse (st.begin (), st.end ());
	int n = st.size (); 
	int dp[n + 1][2];
	for (int i = 0; i < n + 1; i++) {
		for (int j = 0; j < 2; j++) {
			dp[i][j] = MOD;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		int x = st[i] - '0';
		for (int j = 0; j < 2; j++) {
			for (int d = 0; d < 10; d++) {
				if (d - j < x) {
					dp[i + 1][1] = min (dp[i + 1][1], dp[i][j] + d + (10 + d - j - x));
				}
				else {
					dp[i + 1][0] = min (dp[i + 1][0], dp[i][j] + d + (d - j - x));
				}
			}
		}
	}
	cout << min (dp[n][0], dp[n][1] + 1) << "\n";
}
					
			


Measured memory_bytes: 9220
def insertionSort(A):
    for i in range(len(A)):
        v = A[i]
        j = i-1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        for i in range(len(A)):
            if i == len(A)-1:
                print(A[i],end="\n")
            else:
                print(A[i],end=" ")

def main():
    N = int(input())
    A = list(map(int,input().split()))
    insertionSort(A)


if __name__ == "__main__":
    main()


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

VI v;

bool check(int n){
    bool t=false, f=false, s=false;
    int d;
    for(int i=8;i>=0;i--){
        d = n / pow(10,i);
        n -= d*pow(10,i);
        if(d==3) t=true;
        if(d==5) f=true;
        if(d==7) s=true;
    }
    return (t && f && s);
}

void generate(int x, int d){
    if(d >= 9) return;
    int a[] = {3,5,7};
    rep(i,3){
        int y = x + a[i]*pow(10,d);
        if(check(y)) v.push_back(y);
        generate(y, d+1);
    }
}

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

  generate(0, 0);
  sort(v.begin(), v.end());

  int ans = upper_bound(v.begin(), v.end(), n) - v.begin();
  cout << ans << endl;
  
  return 0;
}

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

int main(){
	string a, b;
	cin >> a >> b;

	a += b;

	int num = atoi(a.c_str());

	for(int i = 1; i*i <= num; ++i){
		if(i*i == num){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
p = [0] + LI()

# 左から貪欲に

ans = 0
for i in range(1,N+1):
    if p[i] == i:
        if i < N:
            ans += 1
            p[i],p[i+1] = p[i+1],p[i]
        else:
            ans += 1

print(ans)

Measured memory_bytes: 83520
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100000

// a < b
int gcd(int a, int b) {
    if(a == 0) return b;
    return gcd(b%a, a);
}
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX+2];

    fget_array(&arr[1], num);

    static int cum[NUM_MAX+2];
    static int rcum[NUM_MAX+2];
    int i;
    for(i = 1; i <= num+1; i++) {
        int a = cum[i-1];
        int b = arr[i-1];
        if(a > b) swap(&a, &b);
        cum[i] = gcd(a, b);
    }

    for(i = num; i >= 0; i--) {
        int a = rcum[i+1];
        int b = arr[i+1];
        if(a > b) swap(&a, &b);
        rcum[i] = gcd(a, b);
    }

    int ans = 0;
    for(i = 1; i <= num; i++) {
        int a = cum[i]; // [1, i)
        int b = rcum[i]; // (i, num]
        if(a > b) swap(&a, &b);
        ans = max(ans, gcd(a, b));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  vector<int>vec(3);
  vec.at(0)=a+b;
  vec.at(1)=a-b;
  vec.at(2)=a*b;
  sort(vec.begin(),vec.end());
  cout<<vec.at(2)<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 1005
#define endl "\n"
#define mod 1000000007
ll n,m; ll dp[N][N]; char ar[N][N];
ll maxval(ll i,ll j){
	//cout<<i<<" "<<j<<endl;
	if(i>=n||j>=m){
		return 0;
	}
	if(i==n-1&&j==m-1){
		return 1;
	}
	if(dp[i][j]!=-1){
		return dp[i][j]%mod;
	}

	ll a=0;
	if(i+1<n&&ar[i+1][j]=='.'){
		a+=maxval(i+1,j)%mod;
	}
	if(j+1<m&&ar[i][j+1]=='.'){
		a+=maxval(i,j+1)%mod;
	}
	return dp[i][j]=a%mod;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(i=0;i<n;i++){
		cin>>ar[i];
	}

	k=maxval(0,0)%mod;
	cout<<k;
	return 0;
}


Measured memory_bytes: 9216
H,W=map(int,input().split())

def calc2(H,W):
    if H>W:
        H,W=W,H
        
    if H%2==1 and W%2==1:
        return [H*(W//2),H*W-H*(W//2)]
    else:
        return [H*W//2]
    

def calc(H,H2,W):
    SQ=[H2*W]
    SQ+=calc2(H-H2,W)
    return max(SQ)-min(SQ)

    
ANS=float("inf")
ANS=min(ANS,calc(H,H//3,W))
ANS=min(ANS,calc(H,H//3+1,W))
ANS=min(ANS,calc(W,W//3,H))
ANS=min(ANS,calc(W,W//3+1,H))

print(ANS)

Measured memory_bytes: 3064
#include<iostream>
#include <climits>
#include<vector>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<cassert>
#include<algorithm>
using namespace std;
typedef long long  ll;
typedef long double ld;
//typedef vector<int>        vi;
//typedef vector<ll>        vl;
//#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
//#define pb    push_back;
//#define fo(i,n) for(int i=0;i<n;i++)
//int dp[100005];
//int arr[100005][105];

int main()
{
    int n;
    cin>>n;
    int d1[n],d2[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>d1[i]>>d2[i];
    }
    int ans=0;
    for(int i=n-1;i>=2;i--)
    {
        if(d1[i]==d2[i] && d1[i-1]==d2[i-1] && d1[i-2]==d2[i-2])
        {
            
            ans++;
           // return 0;
            
        }
    }
    if(ans)
        cout<<"Yes";
    else
    cout<<"No";
   
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int memo[100003];
int arr[101],n;

int rek(int x){
	if(x<0) return 1;
	if(x<arr[0]) return 0;
	if(memo[x]!=-1) return memo[x];
	int tr=0;
	for(int i=0;i<n;i++){
		if(rek(x-arr[i])==0) tr=1;
	}
	return memo[x]=tr;
}

int main () {
	int k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	memset(memo,-1,sizeof memo);
	if(rek(k)) cout<<"First";
	else cout<<"Second";



return 0;
}



Measured memory_bytes: 6912
using System;
class Program
{
  static void Main(string[] args)
  {
    string str = Console.ReadLine();
    string stdout = "Yes";

    // wが奇数だったらその時点で美しい文字列でない
    if (str.Length % 2 == 1) {
      stdout = "No";
    }
    else
    {
      // 文字ごとのカウンター
      int[] arry = new int[26];

      foreach(char chr in str)
      {
        switch(chr)
        {
          case 'a':
            arry[0]++;
            break;
          case 'b':
            arry[1]++;
            break;
          case 'c':
            arry[2]++;
            break;
          case 'd':
            arry[3]++;
            break;
          case 'e':
            arry[4]++;
            break;
          case 'f':
            arry[5]++;
            break;
          case 'g':
            arry[6]++;
            break;
          case 'h':
            arry[7]++;
            break;
          case 'i':
            arry[8]++;
            break;
          case 'j':
            arry[9]++;
            break;
          case 'k':
            arry[10]++;
            break;
          case 'l':
            arry[11]++;
            break;
          case 'm':
            arry[12]++;
            break;
          case 'n':
            arry[13]++;
            break;
          case 'o':
            arry[14]++;
            break;
          case 'p':
            arry[15]++;
            break;
          case 'q':
            arry[16]++;
            break;
          case 'r':
            arry[17]++;
            break;
          case 's':
            arry[18]++;
            break;
          case 't':
            arry[19]++;
            break;
          case 'u':
            arry[20]++;
            break;
          case 'v':
            arry[21]++;
            break;
          case 'w':
            arry[22]++;
            break;
          case 'x':
            arry[23]++;
            break;
          case 'y':
            arry[24]++;
            break;
          case 'z':
            arry[25]++;
            break;
        }
      }

      foreach(int cnt in arry)
      {
        if (cnt % 2 == 1) {
          stdout = "No";
        }
      }
    }

    Console.WriteLine(stdout);

  }
}


Measured memory_bytes: 2648
#include<stdio.h>
#include<stdlib.h>
int main()
{
    char ch;
    int res=0;
    ch=getchar();
    while(ch!='\n')
    {
        res+=(ch-'0');
        ch=getchar();
    }
    if(res%9==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 1600
p = input().split()
n,m = int(p[0]), int(p[1])
mi,ma = 1,n
for i in range(m):
    p = input().split()
    l,r = int(p[0]), int(p[1])
    if l > mi:
        mi = l
    if r < ma:
        ma = r
print(max([ma-mi+1,0]))

Measured memory_bytes: 3188
nmx=list(map(int, input().split()))
N=nmx[0]
M=nmx[1]
X=nmx[2]
mylist=[]
for i in range(N):
    mylist.append(list(map(int, input().split())))
Ans=100000*12+1
for i in range(2**N):
    A=[0]*M
    C=0
    for j in range(N):
        if (i>>j) & 1:
            C=C+mylist[j][0]
            for k in range(M):
                A[k]=A[k]+mylist[j][k+1]
    if min(A)>=X:
        Ans=min(Ans, C)
if Ans==100000*12+1:
    print(-1)
else:
    print(Ans)



Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            cout<<"No"<<endl;return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


int main(){
    ll N; cin>>N;
    vector < pair <ll,ll> > task;
    for(int i=0;i<N;i++){
        ll a,b; cin>>a>>b;
        task.push_back(make_pair(b,a));
    }
    sort(task.begin(),task.end());
    ll time = 0;
    bool flag = true;

    for(int i=0;i<N;i++){
        time += task[i].second;
        if(time > task[i].first) {flag = false;break;}
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

      return 0;

}

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

using namespace std;

int main(int argc, char const *argv[]) {
	string s;
	std::cin >> s;
	int w;
	std::cin >> w;

	for (size_t i = 0; i < s.size(); i+=w) {
		std::cout << s[i];
	}
	std::cout << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.ArrayList;
 
class Main
{
  public static void main (String[] arg)
  {
    Scanner scan = new Scanner(System.in);
    
    long a = Long.parseLong(scan.next()); //a
    long b = Long.parseLong(scan.next()); //b
    long c = Long.parseLong(scan.next()); //c
    
    long left = 4 * a * b;
    long d = c - a -b;
    long right = d * d;
    
    if(left < right && d > 0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22228
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int maxTime = sc.nextInt();
        List<Integer> costs = new ArrayList<Integer>();

        for (int i = 0; i < n; i++) {
            int cost = sc.nextInt();
            int time = sc.nextInt();

            if (time <= maxTime)
                costs.add(cost);
        }

        if (costs.size() == 0) {
            System.out.println("TLE");
        } else {
            Collections.sort(costs);
            int minCost = costs.get(0);
            System.out.println(minCost);
        }
    }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;

		do {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				do {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						break;
					} else {
						x /= 10;
					}
				} while (x != 0);
			}
		} while (++i <= n);
		System.out.println();
	}
}

Measured memory_bytes: 28376
#include <stdio.h>
#include <string.h>

int main(void)
{
	int A;
	int B;
	char C[10];

	scanf("%d %s %d", &A, C, &B);

	if (strcmp(C, "+") == 0)
	{
		printf("%d\n", A + B);
	}
	else
	{
		printf("%d\n", A - B);
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
double b[56000];
double c[56000];
int main()
{
	int n;
	cin>>n;
	double x,y;
	cin>>x>>y;
	int a;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		b[i]=x-1.0*a*0.006;
	}
	for(int i=0;i<n;i++)
	{
		c[i]=fabs(b[i]-y);
	}
	double min=1000000.0;
	int k=0;
		for(int i=0;i<n;i++)
		{	
			if(c[i]<min)
		{
			min=c[i];
			k=i+1;
		}
		}
		cout<<k;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
a,b,c=map(int,input().split())
ans=0
if a%2==0 or b%2==0 or c%2==0:
    print(0)
else:
    ans=a*b*c-2*max(a*b*(c//2),c*b*(a//2),a*c*(b//2))
    print(ans)


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

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

    vector<unsigned int> d(n);
    for(unsigned int i = 0; i < n; i++) {
        cin >> d.at(i);
    }
    int result = 0;
    for(unsigned int i = 0; i < n-1; i++) {
        for(unsigned int j = i+1; j<n; j++) {
            result += d.at(i) * d.at(j);
        }
    }
    cout << result;
}


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

def f(x):
    z=[0]*40
    i=1
    while x>0:
        z[-i]=x%2
        x=x//2
        i+=1
    return z

for i in range(n):
    a[i]=f(a[i])

y=[0]*40
for i in range(40):
    y[i]=sum(a[j][i] for j in range(n))%2
ans=[]
for i in range(n):
    p=0
    for j in range(40):
        if y[-j-1]!=a[i][-j-1]:
            p+=2**j
    ans.append(p)
for i in range(n):
    print(ans[i], end=" ")


Measured memory_bytes: 183200
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
} Point;

void kock(int n, Point p1, Point p2){
  
  Point s, t, u;
  
  if(n==0) return ;

  s.x = (2*p1.x+1*p2.x)/3.0;
  s.y = (2*p1.y+1*p2.y)/3.0;
  t.x = (1*p1.x+2*p2.x)/3.0;
  t.y = (1*p1.y+2*p2.y)/3.0;
  u.x = (t.x-s.x)*cos(60*M_PI/180.0)-(t.y-s.y)*sin(60*M_PI/180.0)+s.x;
  u.y = (t.x-s.x)*sin(60*M_PI/180.0)+(t.y-s.y)*cos(60*M_PI/180.0)+s.y;
  
  kock(n-1, p1, s);
  printf("%3.8f %3.8f\n", s.x, s.y);
  kock(n-1, s, u);
  printf("%3.8f %3.8f\n", u.x, u.y);
  kock(n-1, u, t);
  printf("%3.8f %3.8f\n", t.x, t.y);
  kock(n-1, t, p2); 
}

int main(){

  int n;
  Point a, b;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%3.8f %3.8f\n", a.x, a.y);
  kock(n, a, b);
  printf("%3.8f %3.8f\n", b.x, b.y);
  
  return 0;
}

Measured memory_bytes: 640
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)


def lcm(a, b):
    return a // gcd(a, b) * b


def calc(x, a, b):
    return x - x // a - x // b + x // lcm(a, b)


a, b, c, d = map(int, input().split())
print(calc(b, c, d) - calc(a - 1, c, d))


Measured memory_bytes: 3060
#include <stdio.h>
 
typedef struct{
  char suit;
  char value;
} Card;
 
void Bubble(Card *X, int n)
{
  int i, j;
  Card card1;
  for(i = 0; i < n; i++){
    for(j = n-1; j >= i; j--){
      if(X[j].value < X[j-1].value){
    card1 = X[j];
    X[j] = X[j-1];
    X[j-1] = card1;
      }
    }
  }
}
 
void Selection(Card *X, int n)
{
  int i, j, k;
  Card card2;
  for(i = 0; i < n; i++){
    k = i;
    for(j = i; j < n; j++) if(X[j].value < X[k].value) k = j;
    card2 = X[i];
    X[i] = X[k];
    X[k] = card2;
  }
}
 
int TorF(Card *X, Card *Y, int n)
{
  int i, count=0;
  for(i = 0; i < n; i++) if(X[i].suit == Y[i].suit) count++;
  return count;
}
 
void Print(Card *X, int n)
{
  int i;
  for(i = 0; i < n; i++){
    if(i != n-1) printf("%c%c ", X[i].suit, X[i].value);
    else printf("%c%c", X[i].suit, X[i].value);
  }
  printf("\n");
}
 
int main()
{
 
  int n, i;
  Card C1[100], C2[100];
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf(" %c%c",&C1[i].suit,&C1[i].value);
    C2[i] = C1[i];
  }
 
  Bubble(C1, n);
  Selection(C2, n);
 
  Print(C1, n);
  printf("Stable\n");
  Print(C2, n);
  if(TorF(C1, C2, n) == n) printf("Stable\n");
  else printf("Not stable\n");
   
  return 0;
}

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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long n = inputLongArray[0];
            long k = inputLongArray[1];

            // 整数配列の入力(期待値*10に変換してしまう)
            var pArray = Console.ReadLine().Split(' ').Select(i => (long.Parse(i) + 1) * 5).ToArray();

            //とりあえず、1からK番目までの合計を出す
            long max = 0;
            for(long i = 0; i < k; i++)
            {
                max += pArray[i];
            }
            long current = max;
            //Program.Debug.Log($"{k-1} -> {max}");

            //最小を探す
            for (long i = k; i < n; i++)
            {
                long tmp = current + pArray[i] - pArray[i - k];
                //Program.Debug.Log($"{i}: {current} + {pArray[i]} - {pArray[i - k]} -> {tmp}");
                current = tmp;
                if(current > max)
                {
                    max = current;
                }
            }

            Console.WriteLine(max / 10f);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 32896
n,k = map(int, input().split())
r, s, p = map(int, input().split())
scores = {"r":p,"s":r,"p":s}
T = input()
import numpy as np
subT = [""] * k
for i in range(n):
    ind = i % k 
    subT[ind] += T[i]

ans = 0
for S in subT:
    cnt = 0
    prev = "0"
    for i, s in enumerate(S):
        if i == 0:
            ans += scores[s]
        elif prev == s:
            cnt += 1
            if cnt == 2:
                ans += scores[s]
                cnt = 0
        else:
            ans += scores[s]
            cnt = 0
        prev = s
        
        

print(ans)

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

const int NIL = -1;

struct Node
{
        int parent, left, right;
        int sibling, height, depth, degree;
        Node() : parent(NIL), degree(0), sibling(NIL) {}
};

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

int main()
{
        int n;
        Node node[33];

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

                node[u].left = l;
                node[u].right = r;
                if ( l != NIL ) node[l].parent = u, node[l].sibling = r, node[u].degree++;
                if ( r != NIL ) node[r].parent = u, node[r].sibling = l, node[u].degree++;
        }
        
        function < int(int, int) > dfs = [&](int v, int d)
        {
                node[v].height = 0;
                node[v].depth = d;
                if ( node[v].left != NIL ) node[v].height = dfs(node[v].left, d + 1) + 1;
                if ( node[v].right != NIL ) chmax(node[v].height, dfs(node[v].right, d + 1) + 1);
                return ( node[v].height );
        };
        
        for ( int i = 0; i < n; i++ ) {
                if ( node[i].parent == NIL ) {
                        dfs(i, 0);
                        break;
                }
        }

        for ( int i = 0; i < n; i++ ) {
                cout << "node " << i << ": parent = " << node[i].parent;
                cout << ", sibling = " << node[i].sibling;
                cout << ", degree = " << node[i].degree << ", depth = " << node[i].depth;
                cout << ", height = " << node[i].height << ", ";
                if ( node[i].parent == NIL ) cout << "root" << endl;
                else if ( node[i].height == 0 ) cout << "leaf" << endl;
                else cout << "internal node" << endl;
        }

        return ( 0 );
}



Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

string oparate_string(int n,string s) {
  for(int i=1;i<=n;i++) {
    stringstream ss;
    int len = s.length();
    int same = 1;
    for(int l=1;l<len;l++) {
      if(s[l-1] == s[l]) {
        same++;
      }
      else {
        ss << same << s[l-1];
        same = 1;
      }
    }
    ss << same << s[len-1];
    s = ss.str();
  }
  return s;
}

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

  int n;
  string s;
  while(cin >> n && n!= 0) {
    cin >> s;
    cout << oparate_string(n,s) << endl;
  }
}

Measured memory_bytes: 1376
#include <stdio.h>

int main( void )
{
	int i, n[3], N;
	
	scanf("%d", &N);

	for( i=0; i<N; i++ ){
		scanf("%d %d %d", &n[0], &n[1], &n[2]);
		if((n[0]*n[0])+(n[1]*n[1])==n[2]*n[2] ){
			printf("YES\n");
		}else if((n[1]*n[1])+(n[2]*n[2])==n[0]*n[0] ){
			printf("YES\n");
		}else if((n[0]*n[0])+(n[2]*n[2])==n[1]*n[1] ){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 576
<?php

while (($line = trim(fgets(STDIN)))) {
    sscanf($line, '%d %d', $x, $y);

    if ($x === 0 && $y === 0) {
        break;
    }

    $arr = array($x, $y);
    printf('%d %d%s', min($arr), max($arr), PHP_EOL);
}

Measured memory_bytes: 6584
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define mygc(c) (c)=getchar()
#define mypc(c) putchar(c)
#define fi first
#define se second
#define ls(x) t[x].lson
#define rs(x) t[x].rson
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 200005;
const int maxm = 1000005;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
inline void rd(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
inline void rd(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
inline void rd(db *x){scanf("%lf",x);}
inline int rd(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
inline void rd(int a[],int n){FOR(i,0,n)rd(&a[i]);}
inline void rd(ll a[],int n){FOR(i,0,n)rd(&a[i]);}
template <class T, class S> inline void rd(T *x, S *y){rd(x);rd(y);}
template <class T, class S, class U> inline void rd(T *x, S *y, U *z){rd(x);rd(y);rd(z);}
template <class T, class S, class U, class V> inline void rd(T *x, S *y, U *z, V *w){rd(x);rd(y);rd(z);rd(w);}
inline void wr(int x){if(x < 10) putchar('0' + x); else wr(x / 10), wr(x % 10);}
inline void wr(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
inline void wr(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
inline void wr(db x, char c){printf("%.15f",x);mypc(c);}
inline void wr(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
inline void wr(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> inline void wrn(T x){wr(x,'\n');}
template<class T, class S> inline void wrn(T x, S y){wr(x,' ');wr(y,'\n');}
template<class T, class S, class U> inline void wrn(T x, S y, U z){wr(x,' ');wr(y,' ');wr(z,'\n');}
template<class T, class S, class U,class H> inline void wrn(T x, S y, U z,H h){wr(x,' ');wr(y,' ');wr(z,' ');wr(h,'\n');}
template<class T> inline void wra(T x[], int n){int i;if(!n){mypc('\n');return;}FOR(i,0,n-1)wr(x[i],' ');wr(x[n-1],'\n');}
int n,a[maxn];

int main(){
	rd(&n);
	ll ans=0;
	rd(a,n);
	FOR(i,1,n){
		if(a[i]<a[i-1])ans+=a[i-1]-a[i],a[i]=a[i-1];
	}
	wrn(ans);
} 

Measured memory_bytes: 4452
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int k = Integer.parseInt(scan.next());
		int[] a =new int[n];
		for (int i = 0; i < n;++i){
			a[i]=Integer.parseInt(scan.next());
		}
		n-=k;
		int ans=1;
		while (n>0){
			++ans;
			n=n-k+1;
		}

		System.out.print(ans);


}
}
//end

Measured memory_bytes: 48408
import sys
S = input()
T = input()

if T in S:
    print(0)
    sys.exit(0)

ans = []
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    cnt = 0
    for x, y in zip(s, T):
        if x == y:
            cnt += 1
    ans.append(cnt)
    
print(len(T)-max(ans))

Measured memory_bytes: 9052
a,b,c,d = map(int,input().split())
d1 = a-b; d2 = c-b; d3 = a-c

if d1 < 0:
    d1 = -d1
if d2 < 0:
    d2 = -d2 
if d3 < 0:
    d3 = -d3

if d1 <= d and d2 <= d or d3 <= d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
h,w,k=map(int,input().split())
S=[]
for i in range(h):
    s=input().rstrip()
    S.append(s)
ans=[[0]*w for i in range(h)]
nu='.'*w
L={}
a=0
i=0
while S[i]==nu:
    i+=1
c=i
while i<h-1:
    i+=1
    if S[i]==nu:
        pass
    else:
        b=i-1
        L[c]=(a,b)
        c=i
        a=i
b=h-1
L[c]=(a,b)
index=1
for x in L:
    a=0
    i=0
    while S[x][i]=='.':
        i+=1
    while i<w-1:
        i+=1
        if S[x][i]=='.':
            pass
        else:
            b=i-1
            for e in range(L[x][0],L[x][1]+1):
                for f in range(a,b+1):
                    ans[e][f]=index
            index+=1
            a=i
    b=w-1
    for e in range(L[x][0],L[x][1]+1):
        for f in range(a,b+1):
            ans[e][f]=index
    index+=1
for i in range(h):
    for j in range(w-1):
        print(ans[i][j],end='')
        print(' ',end='')
    print(ans[i][w-1])
        
            
    


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int h,w ; 
  cin >> h >> w ;
  rep(i,h){
    rep(j,w){
      string s ;
      cin >> s ;
      if(s == "snuke"){
        cout << (char) (j+65) <<i+1 <<endl ;
        return 0;
      }
    }
  }
        
  
  
}


Measured memory_bytes: 3608
N,M=map(int,input().split())
AC=["false"]*N
WA=[0]*N
wa=0
ac=0
for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        if AC[p-1]=="false":
            AC[p-1]="True"
            ac+=1
            wa+=WA[p-1]
    else:
        WA[p-1]+=1
print(ac,wa)

Measured memory_bytes: 4596
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
 
#define N 112345
#define LO 18
class sbit{
public:
	ll bit[100005];
	ll sum(int i){
		ll ret=0;
		while(i){
			ret+=bit[i];
			i-=i&-i;
		}
		return ret;
	}
	void add(int i, ll x){
		i++;
		while(i<100005){
			bit[i]+=x;
			i+=i&-i;
		}
	}
	void add(int l, int r, ll x){
		add(l, x);
		add(r, -x);
	}
	ll get(int i){
		return sum(i+1);
	}
};

ll k;
vector<pair<int, ll> > path[100005];

int f[100005]; // original node index -> on the list
int c[100005]; // size of subtree
int d[100005]; // depth in tree
int p[100005][LO]; // parent doubling
// int dmm[N];
sbit csm, dsm, qry;

void dfs(int nw, int par, int dep, int ind){
	// printf("dfs(nw=%d, par=%d, dep=%d, ind=%d)\n", nw, par, dep, ind);
	f[nw]=ind;
	d[ind]=dep;
	p[ind][0]=par;
	for(int i=1; i<LO; i++)
	 	p[ind][i]=p[p[ind][i-1]][i-1];
	int sm=1;
	for(int i=0; i<path[nw].size(); i++){
		pair<int, ll> &pr=path[nw][i];
		if(f[pr.first]==par) continue;
		dfs(pr.first, ind, dep+1, ind+sm);
		csm.add(ind+sm, ind+sm+c[ind+sm], pr.second);
		if(pr.second%k==0){
			dsm.add(ind+sm, ind+sm+c[ind+sm], pr.second);
			// dmm[ind+sm]=pr.second;
		}
		sm+=c[ind+sm];
	}
	c[ind]=sm;
}

int lsc(int x, int y){
	if(d[x]<d[y]) swap(x, y);
	int dif=d[x]-d[y];
	for(int i=0; i<LO; i++)
	 	if(dif&(1<<i)) x=p[x][i];
	// printf(" %d %d\n", x, y);
	if(x==y) return x;
	int ret=0;
	for(int i=LO-1; i>=0; i--){
		// printf("(%d, %d)->(%d, %d)\n", x, y, p[x][i], p[y][i]);
		if(p[x][i]==p[y][i]) ret=p[x][i];
		else{
			x=p[x][i];
			y=p[y][i];
		}
	}
	return ret;
}

ll clc(int x){
	int q;
	while((q=qry.get(x))){
		int y=x;
		for(int i=LO-1; i>=0; i--){
			if(qry.get(p[y][i])==q) y=p[y][i];
		}
		dsm.add(y, y+c[y], -(dsm.get(y)-dsm.get(p[y][0])));
		ll r=csm.get(y)-csm.get(p[y][0]);
		if(r%k==0){
			dsm.add(y, y+c[y], r);
		}
		qry.add(y, y+c[y], -(qry.get(y)-qry.get(p[y][0])));
	}
	return csm.get(x)-dsm.get(x);
}

int main(){
	int n;
	cin >> n >> k;
	for(int i=0; i<n-1; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		path[a].push_back(make_pair(b, c));
		path[b].push_back(make_pair(a, c));
	}
	for(int i=0; i<n; i++) f[i]=-1;
	dfs(0, 0, 0, 0);

	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		string s;
		ll x, y;
		cin >> s >> x >> y;
		if(s[0]=='a'){
			x=f[x];
			if(x){
			 	csm.add(x, x+c[x], y);
				qry.add(x, x+c[x], 1);
			}
			csm.add(x+1, x+c[x], y);
			qry.add(x+1, x+c[x], 1);
		}else{
			x=f[x];
			y=f[y];
			int z=lsc(x, y);
			ll ans=clc(x)+clc(y)-2*clc(z);
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 28432
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  string s;
  cin >> n >> s;
  if (s.substr(0,n/2) == s.substr(n/2)) cout << "Yes\n";
  else cout << "No\n";
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a,b,c,x; cin >> a >> b >> c >> x;
    int cnt = 0;
    rep(i, a+1) {
        rep(j,b+1) {
            rep(k,c+1) {
                if(500*i+100*j+50*k == x){
                    cnt++;
                }
                //debug(cnt);
            }
        }
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n-1);
    rep(i, n)cin >> a[i];
    rep(i, n)cin >> b[i];
    rep(i, n-1)cin >> c[i];

    ll ans = 0;
    ll back = -1;
    rep(i, n){
        ans += b[a[i]-1];
        if(back+1==a[i])ans+=c[back-1];
        back = a[i];
    }
    cout << ans << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B < C + D) {cout << "Right" <<endl;
              }
  else if (A + B > C + D) {cout << "Left" <<endl;
}  
  else {cout << "Balanced" <<endl;
       }}

Measured memory_bytes: 256