akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>


using namespace std;

int main() {
    int n;
    int h[100001];
    int a;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a;
        h[i] = a;
    }

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    int x, y;
    for(int i = 0; i < n-2; i++) {
        x = dp[i+1] + abs(h[i+1] - h[i+2]);
        y = dp[i] + abs(h[i] - h[i+2]);
        if(x < y) {
            dp[i+2] = x;
        } else {
            dp[i+2] = y;
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

left = [a[0]]

1.upto(a.size - 2) do |i|
  j = left.size - 1
  left.push(left[j] + a[i])
end

right = [a[a.size - 1]]

(a.size - 2).downto(1) do |i|
  j = right.size - 1
  right.push(right[j] + a[i])
end

result = ((10**9) + 1) * 2
right.reverse!

0.upto(left.size - 1) do |i|
  diff = (left[i] - right[i]).abs
  result = diff if result > diff
end

# p right, left

puts result


Measured memory_bytes: 19780
def main():
    n, k, q = map(int, input().split())
    
    point_list = [(k-q)]*n

    for i in range(q):
        ans_p = int(input())
        point_list[ans_p-1] += 1

    for j in range(n):
        if point_list[j] > 0:
            print('Yes')
        else:
            print('No')





if __name__ == '__main__':
    main()



Measured memory_bytes: 6596
#include <iostream>

typedef long long ll;

const ll MOD = 2019;

int main(){
   ll L, R;
   std::cin >> L >> R;

   ll ans = MOD*MOD;
   if(L/MOD == R/MOD){
      for(int i=L%MOD; i<=R%MOD; ++i){
	 for(int j=i+1; j<=R%MOD; ++j){
	    ans = std::min(ans, i*j%MOD);
	 }
      }
   }else ans = 0;

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


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[20];
int main()
{
    int i,j,k,n,s;
    s=100000;
    scanf("%s",a);
    k=strlen(a);
    for(i=0;i+2<k;i++)
    {
        j=(a[i]-'0')*100+(a[i+1]-'0')*10+(a[i+2]-'0');
        s=min(s,abs(j-753));
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  int ans = 0;
  rep(i, 1, n+1){
    string s = to_string(i);
    if (sz(s)%2==1) ans++;
  }
  cout << ans << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef unsigned long long int ulli;
typedef long long int lli;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

    int r, D;
    ulli x[11];
    cin >> r >> D >> x[0];

    for (int i = 0; i < 10; ++i)
    {
        x[i + 1] = r * x[i] - D;
        cout << x[i + 1] << "\n";
    }


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fastio1 ios_base::sync_with_stdio(false)
#define fastio2 cin.tie(NULL)
#define ll long long
#define MOD 1000000007
using namespace std;
 
int main(){
    fastio1; fastio2;
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	int maxBits = 45;
	ll tracker[maxBits];
	for (int i = 0; i < maxBits; i++){
		tracker[i] = 0;
	}
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
		ll temp = a[i];
		int b = 0;
		while(temp > 0){
			tracker[b] += (temp % 2);
			temp /= 2;
			b++;
		}
	}
	
	
	ll x = 0;
	for (int i = maxBits-1; i >= 0; i--){
		if (tracker[i] < n-tracker[i]){
			if (x + (tracker[i] < n-tracker[i])*(1LL<<i) <= k){
				x += (tracker[i] < n-tracker[i])*(1LL<<i);
			}
		}
	} 
	
	ll total = 0;
	for (int i = 0; i < n; i++){
		total += x^a[i];
	}
	cout << total << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int n = scanner.nextInt();
        int r = scanner.nextInt();
        int c = scanner.nextInt();
        String s = scanner.next();
        String t = scanner.next();

        boolean canGoOut = false;
        // go up
        canGoOut = willGoOut(s, t, r, h -r + 1, 'U', 'D');
        if (canGoOut) {
            System.out.println("NO");
            return;
        }

        // go down
        canGoOut = willGoOut(s, t, h - r + 1, r, 'D', 'U');
        if (canGoOut) {
            System.out.println("NO");
            return;
        }


        // go left
        canGoOut = willGoOut(s, t, c, w - c + 1, 'L', 'R');
        if (canGoOut) {
            System.out.println("NO");
            return;
        }


        // go right
        canGoOut = willGoOut(s, t, w - c + 1, c,'R', 'L');
        if (canGoOut) {
            System.out.println("NO");
            return;
        }
        System.out.println("YES");

    }

    public static boolean willGoOut(
            String s, String t, int needMoves, int cancelNeedMoves, char move, char cancelMove
    ) {
        int cancelMoveCount = 0;
        int moveCount = 0;
        int i;
        for (i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == move) {
                break;
            }
            if (t.charAt(i) == cancelMove) {
                ++cancelMoveCount;
            }
        }
        if (cancelMoveCount >= cancelNeedMoves) {
            cancelMoveCount = cancelNeedMoves - 1;
        }
        moveCount -= cancelMoveCount;
        for (; i < s.length(); ++i) {
            if (s.charAt(i) == move) {
                ++moveCount;
                if (moveCount >= needMoves) {
                    return true;
                }
            }
            if (t.charAt(i) == cancelMove) {
                --moveCount;
            }
        }
        return false;
    }
}


Measured memory_bytes: 29780
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] maze = new char[h + 2][w + 2];
		for(int i = 0; i < h + 2; i++)
			Arrays.fill(maze[i], '#');
		
		for(int i = 1; i < h + 1; i++) {
			char[] c = sc.next().toCharArray();
			for(int j = 1; j < w + 1; j++) {
				maze[i][j] = c[j - 1];
			}
		}
		
		for(int i = 0; i < h + 2; i++) {
			out.println(maze[i]);
		}	

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 21460
#include <stdio.h>
#include <stdlib.h>
#define N 2000000

void sort(int);
void maxheapify(int);
int extract();

int n,arr[N],i=1;
int main(){
  int j,data;
  char com[8];

  while(1){
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n') break;
    else if(com[0] == 'i'){
      scanf("%d",&arr[i]);
      sort(i);
      i++;
    }else{
      i--;
      printf("%d\n",extract());
    }
  }
  return 0;
}

void sort(int node){
  int temp;
  while(node>1 && arr[node/2]<arr[node]){
    temp = arr[node];
    arr[node] = arr[node/2];
    arr[node/2] = temp;
    node=node/2;
  }
}

void maxheapify(int node){
  int left,right,max,temp;
  left=node*2;
  right=node*2+1;
  if(left<=i && arr[left]>arr[node]) max = left;
  else max = node;
  if(right<=i && arr[right]>arr[max]) max = right;
  
  if(max != node){
    temp=arr[node];
    arr[node]=arr[max];
    arr[max]=temp;
    maxheapify(max);
  }
}

int extract(){
  int out=arr[1];
  arr[1]=arr[i];
  maxheapify(1);
  return out;
  
}



Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   long long int h1,m1,h2,m2,k,ans;
   cin>>h1>>m1>>h2>>m2>>k;
   ans=(60-m1)+((h2-(h1+1))*60)+m2;
   cout<<ans-k;
   return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    string a;
    string b;
    string c;
    int i = 0, j =0, k = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    
    
    alice:
    if(i==a.size()){
        cout << "A" << "\n";
        return 0;
        }  else{
   if(a[i] == 'a'){
   i++;
   goto alice;
   }
   else if(a[i]=='b'){
       i++;
       goto bob;
   }else if(a[i]=='c'){
       i++;
       goto c;
   }
   
        }
    
    bob:
       if(j==b.size()){
        cout << "B" << "\n";
        return 0;
        }  else{
   if(b[j] == 'a'){
   j++;
   goto alice;
   }
   else if(b[j]=='b'){
       j++;
       goto bob;
   }else if(b[j]=='c'){
       j++;
       goto c;
   }
   
        }
    
    c:
    
      if(k==c.size()){
        cout << "C" << "\n";
        return 0;
        }  else{
   if(c[k] == 'a'){
   k++;
   goto alice;
   }
   else if(c[k]=='b'){
       k++;
       goto bob;
   }else if(c[k]=='c'){
       k++;
       goto c;
   }
        }
    
    

   bye;

}


Measured memory_bytes: 256
s=list(input())
length=len(s)
idx_half=int((length-1)/2)

if s==s[::-1] and s[:int((length-1)/2)]==s[int((length-1)/2)-1::-1] and s[int((length+3)/2-1):]==s[:int((length+3)/2-2):-1]:    
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9056
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    ll ans = 0;
    ll mn = 0;
    for(int i = 0; i < N; i++){
        ll div = mn + 1;
        ans += (a[i] - 1) / div;

        if(i == 0) mn = 1;
        else if((a[i] - 1) / div == 0){
            mn = max(mn, a[i]);
        }
    }

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


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

int main()
{
    int N, K, X=1;
    cin >> N>>K;

    for (int i = 0; i <N; i++)
    {
        if((X*2)<(X+K)){
            X = X * 2;
        }
        else{
            X = X + K;
        }
    }
    cout << X << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	bitset<18> mask(0);
	Rep(i, k) {
		int b;
		cin >> b;
		mask |= 1 << b;
	}
	BitRep(i, n) {
		bitset<18> bit(i), x;
		x = bit & mask;
		if (x == mask) {
			cout << i << ":";
			Rep(j, n) {
				if (bit[j]) cout << " " << j;
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
int a, b;
int main() {
    while (scanf("%d%d", &a, &b) != EOF) {
        if (a <= 0 && b >= 0) {
                printf("Zero\n");
        }else {
            if (b < 0){
                if ((b - a + 1 )% 2 == 1)
                    printf("Negative\n");
                else
                    printf("Positive\n");
            }else {
                printf("Positive\n");
            }
        }
    }
}


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

using ll = long long;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

// おまけ
long long lcm(long long a, long long b){
    return a * (b / gcd(a, b));
}

int main(){
    ll a, b, c, d;
    std::cin >> a >> b >> c >> d;
    // c, dで割り切れるもの
    ll canC = b / c - (a + c - 1) / c + 1;
    ll canD = b / d - (a + d - 1) / d + 1;
    // cとdで割り切れるもの
    ll LCM = lcm(c, d);
    ll canCD = b / LCM - (a + LCM - 1) / LCM + 1;
    std::cout << (b - a + 1) - (canC + canD - canCD) << std::endl;
    return 0;
}


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

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

int main() {
  int n, m;
  vector<int> a(1000);
  cin >> n >> m;
  int count = 0;
  double No = 0;
  rep(i, n) {
    cin >> a.at(i);
    No += a.at(i);
  }
    // cout << No << endl;
  rep(i, n) {
    if (a.at(i) >= No / (4 * m)) {
      count++;
    }
  }
  if(count >= m) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  }

Measured memory_bytes: 256
const main = (input) => {
  const a = '0abcdefghijklmnopqrstuvwxyz'
  let N = parseInt(input.trim(), 10)

  const ans = []
  while (N > 0) {
    let r = N % 26 || 26

    ans.unshift(a[r])

    N = (N - r) / 26
  }

  return console.log(ans.join(''))
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29536
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int i,j;
    scanf("%d%d",&i,&j);

    printf("%d",(i-1)*(j-1));




    return 0;
}


Measured memory_bytes: 256
/*  ex5_3
    takafumi_ueki*/
#include <stdio.h>
    int main(void){
        int i,j,length,width;
        int row[100]={0};
        int col[100]={0};
        char field[100][100];
        //縦と横の長さを受け取る
        scanf("%d %d",&length,&width);
        //マス目が'.'か'#'かを受け取る
        for(i=0;i<length;i++){
            for(j=0;j<width;j++){
                scanf(" %c",&field[i][j]);
            }
        }
        //列ごとに'#'が含まれているかどうかを調べる
        //もし含まれていたらrow[i]が1になる
        for(i=0;i<length;i++){
            for(j=0;j<width;j++){
                if(field[i][j]=='#'){
                    row[i]=1;
                    break;
                }
            }
        }
        //次に行ごとに'#'が含まれていないか調べる
        for(j=0;j<width;j++){
            for(i=0;i<length;i++){
                if(field[i][j]=='#'){
                    col[j]=1;
                    break;
                }
            }
        }
        //もし,'#'がひとつでも含まれていたらその行、列は書き出すようにする
        for(i=0;i<length;i++){
            for(j=0;j<width;j++){
                if(row[i]==1&&col[j]==1){
                    printf("%c",field[i][j]);
                }
            }
            printf("\n");
        }
        return 0;
    }


Measured memory_bytes: 128
S = input()

if S == 'SUN':
	print('7')
elif S == 'MON':
	print('6')
elif S == 'TUE':
	print('5')
elif S == 'WED':
	print('4')
elif S == 'THU':
	print('3')
elif S == 'FRI':
	print('2')
elif S == 'SAT':
	print('1')


Measured memory_bytes: 2940
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
txy = np.array([iarr() for i in range(n)])
# 要素数はn+1
txy = np.concatenate((np.zeros((1,3),int),txy))
t,x,y = txy.T[0], txy.T[1], txy.T[2]

flag = 1
for i in range(n):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    time = abs(t[i+1] - t[i])
    if time < dist: flag = 0; break
    if (time - dist)%2 == 1: flag = 0; break

ans = "Yes" if flag else "No"
print(ans)


Measured memory_bytes: 41404
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e8+1;
int main()
{
    FASTINOUT;
    int n;
    cin>>n;
    ll a=2,b=1,c;
    for (int i=2;i<=n;i++){
        c=a+b;
        a=b;
        b=c;
    }
    cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define RE return
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    string s;
	cin>>s;
	if(s.size()==6&&s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes\n";
	else cout<<"No\n"; 
    RE 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
}


Measured memory_bytes: 256
from queue import Queue
INF = 999999


H, W = map(int, input().split())
S = [input() for x in range(H)]

m = 0
for si in range(H):
    for sj in range(W):
        if S[si][sj] == '#':
            continue
        
        q = Queue()
        q.put((si, sj, 0))
        done = [None] * H
        for i in range(H):
            done[i] = [False] * W
        done[si][sj] = True

        unit = ((1, 0), (-1, 0), (0, 1), (0, -1))
        while not q.empty():
            i, j, w = q.get()

            for u in unit:
                nexti = i + u[0]
                nextj = j + u[1]
                if nexti >= 0 and nexti < H and nextj >= 0 and nextj < W and S[nexti][nextj] == '.' and (not done[nexti][nextj]):
                    q.put((nexti, nextj, w+1))
                    m = max(m, w + 1)
                    done[nexti][nextj] = True
print(m)


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

const ll N = 100005;

ll n, m, k, cc, c[N], p[2*N], ans;

vector<pair<ll, pll> > e;
vector<ll> v;

ll Find (ll X) {
	if(p[X] == X) return X;
	return p[X] = Find(p[X]);
}

int main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	for(ll i=1;i<=n;i++) {
		scanf("%lld",&c[i]);
	}
	iota(p+1, p+1+n+k, 1);
	cc = k;
	for(ll i=1;i<=m;i++) {
		ll A, B, C;
		scanf("%lld%lld%lld",&A,&B,&C);
		if(!c[A]) c[A] = ++cc;
		if(!c[B]) c[B] = ++cc;
		e.push_back({C, {c[A], c[B]}});
	}
	sort(e.begin(), e.end());
	for(auto &T : e) {
		ll A = T.Y.X, B = T.Y.Y, C = T.X;
		A = Find(A);
		B = Find(B);
		if(A == B) continue;
		p[A] = B;
		v.push_back(C);
	}
	if(v.size() < k-1) {
		puts("-1");
		return 0;
	}
	for(ll i=0;i<k-1;i++) {
		ans += v[i];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 7152
PROGRAM-ID.                      ABC_106_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(7).
    01 A       PIC 9(3).
    01 B       PIC 9(3).
    01 tmp     PIC 9(5).
    01 ans     PIC X(5).

    01 ZS      PIC Z(5)9.
    01 DUMMY   PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO A B.

    COMPUTE tmp = A * B - (A + B - 1).
    MOVE tmp TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 636
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
s = list(input().rstrip())

rcnt = s.count("R")
gcnt = s.count("G")
bcnt = s.count("B")
total = rcnt * gcnt * bcnt

for i, ch in enumerate(s):
    left = s[:i]
    right = s[i+1:]
    left.reverse()
    for ll, rr in zip(left, right):
        if ll != rr and ll != ch and rr != ch:
            total -= 1

print(total)

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

#define int long long
#define MOD 1000000007

signed main(){
    int n, k;
    cin >> n >> k;

    int a[2010];
    for(int i = 0;i < n;i++) cin >> a[i];

    int ans = 0;
    for(int i = 0;i < n;i++){
        int c1 = 0;
        int c2 = 0;
        for(int j = 0;j < i;j++){
            if(a[i] > a[j]){
                c1++;
            }
        }

        for(int j = i+1;j < n;j++){
            if(a[i] > a[j]){
                c2++;
            }
        }

        ans = (ans + (c1 * (((k * (k-1))/2)%MOD) ) % MOD + (c2 * (((k*(k+1))/2) % MOD) ) % MOD) % MOD;

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    s = list(map(int,input().strip().split()))
    tmp = s[0]
    s[0] = s[1]
    s[1] = tmp

    tmp = s[0]
    s[0] = s[2]
    s[2] = tmp

    print("{} {} {} ".format(s[0],s[1],s[2]))
main()


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

int main() {
	int H, W;

	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i % 2 == 0) {
					if (j % 2 == 0)cout << '#';
					else cout << '.';
				}
				if (i % 2 == 1) {
					if (j % 2 == 1)cout << '#';
					else cout << '.';
				}
			}
			cout << '\n';
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    let x = lines[0].split(' ').map( _ => parseInt(_))
    /* let p = lines[1].split(' ').map( _ => parseInt(_)) */

    for(let i = 0; i < 5; i++) {
        if(x[i] == 0) {
            console.log(i+1)
        }
    }
});

Measured memory_bytes: 29912
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

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

int main(){
int N,K;
cin>>N>>K;
ll x[N];
rep(i,N)cin>>x[i];

ll sum=0;
ll min_=1e9;
rep2(i,1,K)sum+=abs(x[i]-x[i-1]);
min_=sum+min(abs(x[0]),abs(x[K-1]));
rep2(i,K,N){
    sum+=abs(x[i]-x[i-1]);
    sum-=abs(x[i-K+1]-x[i-K]);
    min_=min(min_,sum+min(abs(x[i-K+1]),abs(x[i])));
}
cout<<min_<<endl;
return 0;
}

Measured memory_bytes: 4376
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,e[100001];
bool a[200001][2];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d",&e[i]);
		a[e[i]][1]=true;
		a[e[i]][2]=true;
	}
	for (int i=m;i>=1;i--)
	{
		if (a[e[i]][1]==true&&a[e[i]][2]==true)
		{
			printf("%d\n",e[i]);
			a[e[i]][2]=false;
		}
	}
	for (int i=1;i<=n;i++)
	{
		if (a[i][1]==false) 
		{
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 3484
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
typedef long long ll;

int main()
{	
	int n;
	cin>>n;
	ll a;
	int max=1;
	ll cnt=0;
	
	cin>>a;
	cnt+=a-1;
	max=2;
	
	rep(i,n-1){
		cin>>a;
		cnt+=(a-1)/max;
			if(max==a)
				max = a+1;
	}
	
	cout<<cnt<<endl;
	
	
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int n;
  string s;
  cin >> n >> s;
  int w = 0, e = 0;
  for(int i = n - 1;i >= 0;i --){
    if(s[i] == 'E'){
      e ++;
    } 
  }
  int ans = INF;
  rep(i, n){
    if(s[i] == 'W'){
      ans = min(ans, e + w);
      w ++;
    } else {
      e --;
      ans = min(ans, e + w);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 720
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_079_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(4).
    01 D      PIC 9(4).
    01 R      PIC 9(1).
    01 cnt    PIC 9(1).
    01 bk     PIC 9(1).
    01 mx     PIC 9(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    MOVE N TO D.

    DIVIDE 10 INTO D GIVING D REMAINDER bk.

    MOVE 0 TO mx.

    MOVE 1 TO cnt.

    PERFORM UNTIL D = 0
        DIVIDE 10 INTO D GIVING D REMAINDER R

        IF bk = R THEN
            ADD 1 TO cnt
        ELSE
            MOVE 1 TO cnt
        END-IF

        MOVE R TO bk

        COMPUTE mx = FUNCTION MAX(mx, cnt)
    END-PERFORM.

    IF 3 <= mx THEN
        DISPLAY "Yes"
    ELSE
        DISPLAY "No"
    END-IF.

    STOP RUN.


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[100000];
int main() {
  int n, k;
  cin >> n >> k;
  rep(i,n)
    cin >> a[i];
  if(n <= k) cout << 1 << endl;
  else{
    int ans = 1 + (n-k) / (k-1) + ((n-k)%(k-1) ? 1 : 0);
    cout << ans << endl;
  }
  return 0;
}



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

prime_array = [
    2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
    73, 79, 83, 89, 97
]
prime_count = [0] * 25

for n in range(1, N + 1):
    for i, j in enumerate(prime_array):
        if n < j:
            break
        while n % j == 0:
            prime_count[i] += 1
            n = n / j

# print(prime_count)

can_use_count = [0] * 5  # 2,4,14,24,74

for i in prime_count:
    if i >= 2:
        can_use_count[0] += 1
    if i >= 4:
        can_use_count[1] += 1
    if i >= 14:
        can_use_count[2] += 1
    if i >= 24:
        can_use_count[3] += 1
    if i >= 74:
        can_use_count[4] += 1

ans = 0
ans += can_use_count[4]  # a^74
ans += can_use_count[3] * (can_use_count[0] - 1)  # a^24 * b^2
ans += can_use_count[2] * (can_use_count[1] - 1)  # a^14 * b^4
ans += can_use_count[1] * (
    can_use_count[1] - 1) / 2 * (can_use_count[0] - 2)  # a^4 * b^4 * c^2

print(int(ans))

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

int main() {
    int n, m, x, y;
    int jewel_position[21][21];

    while (cin >> n && n) {
        for (int i=0; i<21; i++) {
            for (int j=0; j<21; j++) {
                jewel_position[i][j] = 0;
            }
        }

        for (int i=0; i<n; i++) {
            cin >> x >> y;
            jewel_position[x][y] = 1;
        }

        cin >> m;
        int x_pos = 10, y_pos = 10;
        for (int i=0; i<m; i++) {
            string direction;
            int amount;
            cin >> direction;
            cin >> amount;
            if (direction == "N") {
                for (int j=0; j<amount; j++) {
                    y_pos += 1;
                    jewel_position[x_pos][y_pos] = 0;
                }
            } else if (direction == "E") {
                for (int j=0; j<amount; j++) {
                    x_pos += 1;
                    jewel_position[x_pos][y_pos] = 0;
                }
            } else if (direction == "W") {
                for (int j=0; j<amount; j++) {
                    x_pos -= 1;
                    jewel_position[x_pos][y_pos] = 0;
                }
            } else {
                for (int j=0; j<amount; j++) {
                    y_pos -= 1;
                    jewel_position[x_pos][y_pos] = 0;
                }
            }
        }
        
        bool f = true;
        for (int i=0; i<21; i++) {
            for (int j=0; j<21; j++) {
                if (jewel_position[i][j]) {
                    f = false;
                }
            }
        }
        if (f) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1200
def calc_cost(h):
    if (len(h) == 0):
        return 0
 
    cost = [None] * len(h)
    cost[0] = 0
    for i in range(1, len(h)):
        cost[i] = cost[i-1] + abs(h[i] - h[i-1])
        if i>1:
            cost[i] = min(cost[i], cost[i-2] + abs(h[i] - h[i-2]))
 
    return cost[len(h)-1]
 
if __name__ == "__main__":
    n = int(input())
    h = list(map(int, input().split(" ")))
    res = calc_cost(h)
    print(res)

Measured memory_bytes: 13776
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>	// istringstream
using namespace std;

int main(){
	int n, ansBangou = 0, maxNum = -1;
	int bangou = 0, num = -1;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> bangou >> num;
		if (maxNum < num){
			maxNum = num;
			ansBangou = bangou;
		}
		else if (maxNum == num){
			ansBangou = min(ansBangou, bangou);
		}
	}
	cout << ansBangou << " " << maxNum << endl;

	return 0;
}

Measured memory_bytes: 1164
use proconio::input;

#[allow(unused_imports)]
use std::collections::HashSet;

use std::cmp;


fn main() {
    input! {
        n: usize,
        k: usize,
    }
    solve(n, k);
}

fn prepare(m: usize, k: usize, p :u64) -> Vec<Vec<u64>> {
    let mut v : Vec<Vec<u64>> = Vec::<Vec<u64>>::with_capacity(m + 1);
    let v0 : Vec<u64> = vec![1; 1];
    v.push(v0);
    for i in 1..m+1 {
        
       let mut vi : Vec<u64>;
        if i < 2 * k {
            let jmax = cmp::min(i, k);
            vi = vec![0; jmax+1];
            for j in 0..i/2+1 {
                vi[j] = 
                if j == 0 || j==i {
                    1
                } else {
                    (v[i-1][j-1] + v[i-1][j]) % p
                };
                if i-j <= jmax {
                    vi[i-j] = vi[j];
                }
            }
            v.push(vi);
        } else {
            vi = vec![0; k+1];
            for j in 0..k+1 {
                vi[j] = 
                if j == 0 || j==i {
                    1
                } else {
                    (v[i-1][j-1] + v[i-1][j]) % p
                };
            }
            v.push(vi);
        }
    }
    return v;
}

fn solve(n: usize, k: usize) {
    let p : u64 = (10u32.pow(9u32) + 7) as u64;

    // 1. Calculate values of combinations
    let m = cmp::max(k-1, n-k+1);
    let c = prepare(m, k, p);

    // 2. Calculate possible ways
    for i in 1..k+1 {
        let b = c[k-1][i-1];
        let r = if i > n-k+1 { 
            0
        } else {
            c[n-k+1][i]
        };
        let t = b * r % p;
        println!("{}", t);
    }
}


Measured memory_bytes: 17664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    string s;
    cin >> s;
    string t = "AAA";
    string r = "BBB";
    if(s == t || s == r) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

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

int main() {
  string c;
  cin >> c;
if(c == "a" || c== "i" || c== "u" || c== "e" || c== "o"){
      cout << "vowel" << endl;

}

else{
cout << "consonant" << endl;
}



}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 2000005;
const int maxm = 105;
const int inf = 1<<29;

int ehead[maxn],ecnt=1;
struct edge {
	int u,v,vol,next;
}edg[maxn];
void add(int u,int v,int w) {
	edg[++ecnt]=(edge){u,v,w,ehead[u]};
	ehead[u]=ecnt;
	edg[++ecnt]=(edge){v,u,0,ehead[v]};
	ehead[v]=ecnt;
}

char g[maxm][maxm];
int col[maxm],row[maxm];
int in[maxm][maxm];
int out[maxm][maxm];
int S,T,cnt,n,m;

namespace dinic {
	int que[maxn],head,tail,lab[maxn];
	bool bfs() {
		memset(lab,-1,cnt+1<<2);
		que[head=tail=0]=S;lab[S]=1;
		while (head<=tail) {
			int u=que[head++];
			for (int v,j=ehead[u];j;j=edg[j].next)
			if (edg[j].vol&&lab[v=edg[j].v]==-1)
				lab[v]=lab[u]+1,que[++tail]=v;
		}
		return lab[T]!=-1; 
	}
	int dfs(int u,int cur) {
		int res=0;
		if (u==T) return cur;
		for (int v,j=ehead[u];j&&res<cur;j=edg[j].next)
		if (edg[j].vol&&lab[v=edg[j].v]==lab[u]+1) {
			int tmp=dfs(v,min(cur-res,edg[j].vol));
			edg[j].vol-=tmp;edg[j^1].vol+=tmp;res+=tmp;
		}
		if (!res) lab[u]=-1;
		return res;
	}
	int main() {
		int res=0;
		while (bfs()&&res<inf) res+=dfs(S,inf);
		return res>=inf?-1:res;
	}
}
int main()
{
	#ifdef Amberframe
		freopen("arc074f.in","r",stdin);
		freopen("arc074f.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);S=++cnt;T=++cnt;
	for (int i=1;i<=n;i++) scanf("%s",g[i]+1);
	for (int i=1;i<=n;i++) row[i]=++cnt;
	for (int i=1;i<=m;i++) col[i]=++cnt;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	if (g[i][j]!='.') {
		in[i][j]=++cnt;out[i][j]=++cnt;
		if (g[i][j]=='S') add(S,out[i][j],inf);
		if (g[i][j]=='T') add(in[i][j],T,inf);
		add(out[i][j],row[i],inf);
		add(out[i][j],col[j],inf);
		add(row[i],in[i][j],inf);
		add(col[j],in[i][j],inf);
		add(in[i][j],out[i][j],1);
	}
	printf("%d",dinic::main());
	return 0;
}

Measured memory_bytes: 8448
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
//map<int,int> m;
long long n,m,sum,cnt;
iint a[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	if(n>m) cout<<"safe"<<endl;
	else{
		cout<<"unsafe"<<endl;
	}



}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min({abs(a[i-1]-a[i])+dp[i-1],abs(a[i-2]-a[i])+dp[i-2]});
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
import sys
import numpy as np

from numba import njit


@njit('i4(i4,i4[:])', cache=True)
def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = np.zeros(nsq, dtype=np.int16)
    is_seated = np.zeros(nsq, dtype=np.int8)
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = np.array([-n2, -1, 1, n2], dtype=np.int32)

    ans = 0

    for pi in range(n * n):
        i, j = divmod(ppp[pi], n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        q = []
        for mi in range(4):
            ni = i + MOVES[mi]
            if seats[ni] > res:
                seats[ni] = res
                q.append(ni)

        while q:
            j = q.pop()
            # print(val, j, seats[j], l, r)
            val = seats[j]

            if is_seated[j]:
                val += 1
            for mi in range(4):
                nj = j + MOVES[mi]
                if seats[nj] > val:
                    seats[nj] = val
                    q.append(nj)

        # print(ppp[pi] + 1, i, ans)
        # print(seats.reshape((n2, n2)))
        # print(is_seated.reshape((n2, n2)))

    return ans


n = int(sys.stdin.buffer.readline())
ppp = np.array(list(map(int, sys.stdin.buffer.read().split())), dtype=np.int32) - 1

# n = 20
# np.random.seed(seed=32)
# ppp = np.random.permutation(n * n).astype(np.int32)
# print(ppp)

print(solve(n, ppp))


Measured memory_bytes: 131784
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int A =0;
        for (int i = 1; i <= N; i++){
            A += sc.nextInt();
        }
        if (A>=H) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 48536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

const int MAXN = 405;
const int MAXM = 100005;

int n,m,ans;
int u[MAXM];
int v[MAXM];

bool ok[MAXN];
bool vis[MAXN][MAXN];

int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1;i <= m;i++)
		scanf("%d%d",&u[i],&v[i]);
	for (int i = 1;i <= n;i++)
	{
		vis[i][i] = 1;
		ok[i] = 1;
		for (int j = m;ok[i] && j >= 1;j--)
		{
			if (vis[i][u[j]] && vis[i][v[j]])
				ok[i] = 0;
			else if (vis[i][u[j]])
				vis[i][v[j]] = 1;
			else if (vis[i][v[j]])
				vis[i][u[j]] = 1;
		}
	}
	for (int i = 1;i <= n;i++)
		for (int j = i + 1;j <= n;j++)
		{
			if (!ok[i] || !ok[j])
				continue;
			bool fl = 1;
			for (int k = 1;k <= n && fl;k++)
				if (vis[i][k] && vis[j][k])
					fl = 0;
			ans += fl;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
n, m = map(int, input().split())
number = [0] * n
cou = [0] * n
#logging.debug(number)#

for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if cou[s] > 0 and c != number[s]:
        print(-1)
        exit()
    else:
        cou[s] += 1
        number[s] = c
    #logging.debug("number = {}, cou = {}".format(number, cou))

if n > 1 and number[0] == 0 and cou[0] >= 1:
    print(-1)
    exit()
elif n > 1 and number[0] == 0:
    number[0] = 1

number = map(str, number)
print(''.join(number))

Measured memory_bytes: 9116
#include <iostream>

using namespace std;


int main(){
    
    int H, W;

    while(true){
        cin >> H >> W;
        if(H!=0 && W!=0){
            for(int i=0; i<H; i++){
                if(i%2==0){
                    for(int j=0; j<W; j++){
                        if(j%2==0){
                            cout << "#";
                        }else{
                            cout << ".";
                        }
                    }
                }else{
                    for(int j=0; j<W; j++){
                        if(j%2!=0){
                            cout << "#";
                        }else{
                            cout << ".";
                        }
                    }
                }
                cout << endl;
            }
            cout << endl;
        }else{
            break;
        }
    }

    return 0;
}




Measured memory_bytes: 3084
import sys

def main():
    input = sys.stdin.readline
    A = [int(input()) for _ in range(5)]

    ans = 0
    B = []
    for a in A:
        if a % 10 == 0:
            ans += a
        else:
            B.append(a)

    B = sorted(B, key=lambda x: -(x%10))
    n = len(B)
    for i in range(n-1):
        ans += (B[i] // 10 + 1) * 10

    if n > 0:
        ans += B[n-1]


    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064