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

#define ll long long

int H, W, K, ans, tmp, judge;
bool flag;

void solve() {
    std::cin >> H >> W >> K;
    std::vector<std::string> c(H);
    for (int i=0; i<H; ++i)
        std::cin >> c[i];
    ans = 2000;
    
    for (int bit=0; bit<(1 << H-1); ++bit) {
        tmp = 0;
        std::vector<int> arr1;
        arr1.push_back(0);
        for (int j=0; j<(H-1); ++j) {
            if(1 & bit >> j){
                arr1.push_back(j+1);
                tmp++;
            }
        }
        arr1.push_back(H);
        if (ans < tmp)
            continue;
        
        std::vector<int> arr2(arr1.size()-1);
        judge = 0;
        flag = false;
        for (int i=0; i<W; ++i) {
            for (int j=0; j<arr1.size()-1; ++j) {
                for (int k=arr1[j]; k<arr1[j+1]; k++){
                    if (c[k][i]== '1')
                        arr2[j]++;
                }
            }
            for (int j=0; j<arr2.size(); ++j) {
                if (arr2[j] > K) {
                    for (int k=0; k<arr2.size(); ++k)
                        arr2[k] = 0;    
                    if (judge==0) {
                        flag=true;
                        break;            
                    }
                    tmp++;     
                    i--;
                    judge=0;
                    break;
                }
                if (j == arr2.size()-1)
                    judge++;
            }
            if (flag)
                break;
        }
        if (judge)
            ans = std::min(ans,tmp);
    }
    std::cout << ans << std::endl;
}
 
int main() {
    std::ios_base::sync_with_stdio(0);
    solve();
    return 0;
}


Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
  Scanner sc;
 
  class Circle {
    byte x, y, r, c;
 
    Circle(byte x, byte y, byte r, byte c) {
      this.x = x;
      this.y = y;
      this.r = r;
      this.c = c;
    }
 
    boolean intersect(Circle o) {
      return ( (int) r + o.r ) * ( (int) r + o.r ) > ( (int) x - o.x )
          * ( (int) x - o.x ) + ( (int) y - o.y ) * ( (int) y - o.y );
    }
  }
 
  int n = 24;
  Circle[] list = new Circle[n];
  boolean[] done = new boolean[n];
  byte[] memo = new byte[1 << n];
  boolean[] fill = new boolean[1 << n];
 
  byte dfs(int BITS) {
    if ( fill[ BITS ] ) {
      return memo[ BITS ];
    }
    byte max = 0;
 
    for ( int i = 0; i < n; ++i ) {
      if ( done[ i ] || !isTop( i ) )
        continue;
      for ( int j = i - 1; 0 <= j; --j ) {
        if ( done[ j ] || !isTop( j ) )
          continue;
 
        if ( list[ i ].c == list[ j ].c ) {
          done[ i ] = done[ j ] = true;
          max = (byte) Math
              .max( max, 2 + dfs( BITS | ( 1 << i ) | ( 1 << j ) ) );
          done[ i ] = done[ j ] = false;
        }
      }
    }
 
    fill[ BITS ] = true;
    memo[ BITS ] = max;
    return max;
  }
 
  boolean isTop(int index) {
    boolean flag = true;
    for ( int i = index - 1; 0 <= i; --i ) {
      flag &= done[ i ] | !list[ i ].intersect( list[ index ] );
    }
    return flag;
  }
 
  void run() {
    for ( ;; ) {
      n = ni();
      if ( n == 0 ) {
        break;
      }
 
      Arrays.fill( done, false );
      Arrays.fill( fill, false );
      for ( int i = 0; i < n; ++i ) {
        byte x = ni();
        byte y = ni();
        byte r = ni();
        byte c = ni();
        list[ i ] = new Circle( x, y, r, c );
        // debug(isTop(i));
      }
 
      System.out.println( dfs( 0 ) );
    }
  }
 
  Main() {
    sc = new Scanner( System.in );
  }
 
  byte ni() {
    return (byte) sc.nextInt();
  }
 
  public static void main(String[] args) {
    new Main().run();
  }
 
  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
 
}

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

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		cout << a[0];
		for (int k = 1; k < n; k++) {
			cout << " " << a[k];
		}
		cout << endl;
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
	cout << a[0];
	for (int k = 1; k < n; k++) {
		cout << " " << a[k];
	}
	cout << endl;
	delete[] a;
	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<list>

using namespace std;
int main(){
	int a, b, c;
	int max = 0;
	int count = 0;


	cin >> a;

	cin >> b;

	for (int i = 1; i < a; i++) {
		cin >> c;
		
		if (b >= c) {
			count++;
		}
		else {
			if (max < count) {
				max = count;
			}
			count = 0;
		}
		b = c;
	}
	
	if (max < count) {
		max = count;
	}

	cout << max << endl;

	return 0;
}

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

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

int main() {
  int A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
     #define int long long
            #define mod  1000000007
            #define pa pair<int,int>
            #define ll long long
            #define pal pair<double,int>
            #define ppa pair<int,pa>
            #define ssa pair<string,int>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     //priority_queue<int, vector<int>, greater<int> > que;
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
string itos( int i ) {
ostringstream s ;
s << i ;
return s.str() ;
}

int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
double distans(double x1,double y1,double x2,double y2){
	double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
	return sqrt(rr);
	
}
 
int beki(int a, int r){
	if(r==0)return 1;
	if(r==1) return a%mod; 
	if(r%2==1){
		int y=beki(a,r-1);
		return(y*a)%mod;
		
	}
	int yy=beki(a,r/2);
	return (yy*yy)%mod;
}
 
 int inf=mod*2;
 
 int kai[100000];
 int inv[100000];
int memo[1004][1004]={0};
            //----------------kokomade tenpure------------
int n,a[1003];
    signed  main(){
    	int z,zz,zzz,zzzz;
  cin>>z>>zz>>zzz>>zzzz;
    	cout<<max(z*zz,zzz*zzzz)<<endl;
    //	cout<<memo[b][n]%mod<<endl;
    	return 0;
    }
    //printf("%d %.10f %.10f\n",i,xx/ri,yy/ri);

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(3)), dp(n + 1, vector<int>(3));
  for (int i = 0; i < n; i++) for (int j = 0; j < 3; j++) cin >> a.at(i).at(j);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        dp.at(i + 1).at(j) = max(dp.at(i + 1).at(j), dp.at(i).at(k) + a.at(i).at(j));
      }
    }
  }
  cout << *max_element(dp.at(n).begin(), dp.at(n).end()) << endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N;
    string S;
    cin >> N;
    cin >> S;

    ll R = 0, G = 0, B = 0;
    REP(i,0,N) {
        if(S[i] == 'R') ++R;
        else if(S[i] == 'G') ++G;
        else if(S[i] == 'B') ++B;
    }

    ll cnt = R * G * B;
    REP(i,0,N-2) {
        REP(j,i+1,N-1) {
            ll k = 2 * j - i;
            if(k < N) {
                if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) --cnt;
            }
        }
    }
    PR(cnt);

    return 0;
}

/*



*/

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	long long n,a,b; cin >> n >> a >> b;
	if((b-a)%2 == 0) cout << (b-a)/2 << "\n";
	else cout << min(a-1, n-b) + 1 + (b-a-1)/2 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N=pow(10,9)+7; 

ll pow_mod(ll x){
    ll ans = 1;
    for(int i=0; i<x; i++){
        ans = (ans*2)%N;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    vector<int> cnt(n,0);
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        cnt.at(a)++;
    }
    bool possible=true;
    if(n%2==1){
        if(cnt.at(0)!=1) possible=false;
        for(int i=1; i<n; i++){
            if(i%2==0 && cnt.at(i)!=2) possible=false;
            if(i%2==1 && cnt.at(i)!=0) possible=false;
        }
    }
    else{
        for(int i=0; i<n; i++){
            if(i%2==0 && cnt.at(i)!=0) possible=false;
            if(i%2==1 && cnt.at(i)!=2) possible=false;
        }
    }
    if(possible) cout << pow_mod(n/2) << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3760
s = [i for i in input()]
for i in range(1,len(s)//2):
  count = 0
  for j in range(len(s)//2-i):
    if s[j] == s[j+len(s)//2-i]:
      count += 1
    if count == len(s)//2-i:
      print(len(s)-i*2)
      exit()

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

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;

    rep(i, dy) cout << 'U';
    rep(i, dx) cout << 'R';
    rep(i, dy) cout << 'D';
    rep(i, dx + 1) cout << 'L';
    rep(i, dy + 1) cout << 'U';
    rep(i, dx + 1) cout << 'R';
    cout << 'D';
    cout << 'R';
    rep(i, dy + 1) cout << 'D';
    rep(i, dx + 1) cout << 'L';
    cout << 'U' << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	first := A[0]
	num := 0
	for i := N - 1; i >= 1; i-- {
		if i%2 == 0 {
			num += A[i]
		} else {
			num -= A[i]
		}
	}
	ans := make([]int, N)
	ans[0] = first + num
	for i := 1; i < N; i++ {
		one := ans[i-1] / 2
		two := A[i-1] - one
		ans[i] = 2 * two
	}

	for i := 0; i < N; i++ {
		if i != 0 {
			fmt.Fprint(wtr, " ")
		}
		fmt.Fprint(wtr, ans[i])
	}
	fmt.Fprintln(wtr)
}


Measured memory_bytes: 5760
# 初期入力
K = int(input())

#
runrun_su = [i for i in range(1,10)]
tyusi = False
while tyusi ==False:
    if K< len(runrun_su):
        print(runrun_su[K-1])
        tyusi =True 
        break
    else:
        for i in runrun_su:
            i_mod_10 = i % 10
            if 1<= i_mod_10 and i_mod_10 < 9:           # 通常3つ増える
                runrun_su.append(10*i + i_mod_10 -1)
                runrun_su.append(10*i + i_mod_10   )
                runrun_su.append(10*i + i_mod_10 + 1)

            elif i % 10 ==9:                            # 位が上がる前
                runrun_su.append(10*i +i_mod_10 -1)
                runrun_su.append(10*i +i_mod_10   )
            elif i % 10 ==0:                            # 位が上がった後
                runrun_su.append(10*i )
                runrun_su.append(10*i +1)
            #print(runrun_su)
            if K< len(runrun_su):
                print(runrun_su[K-1])
                tyusi =True 
                break

Measured memory_bytes: 7188
S=str(input())
if S[0]==S[1]:
    if S[2]==S[3] and S[1]!=S[2]:
        print("Yes")
    else:
        print("No")
else:
    if S[0]==S[2] and S[1]==S[3]:
        print("Yes")
    elif S[0]==S[3] and S[1]==S[2]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    static long steps[];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Set<Integer> a = new HashSet<Integer>(M);
        steps = new long[N+1];
        for(int i=1; i<=M; i++) {
            int tmp = sc.nextInt();
            a.add(tmp);
        }

        if(N<=1) {
            System.out.println(1L);
            return;
        }
        steps[0] = 1L;
        steps[1] = a.contains(1) ? 0L : 1L;
        for(int i=2; i<=N; i++) {
            steps[i] = a.contains(i) ? 0L : (steps[i-2] + steps[i-1]) % 1000000007L;
        }
        System.out.println(steps[N]);
    }
}

Measured memory_bytes: 62460
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);
using namespace std;
int main(){
	fast;
	int a,b,c;
	char s1;
	cin>>a>>s1>>b>>s1>>c;
	if(a==2019&&b==4&&c==30){
		cout<<"Heisei";
		return 0;
	}
	if(a<2019){
		cout<<"Heisei";
		return 0;
	}
	if(b<4&&a==2019){
		cout<<"Heisei";
		return 0;
	}
	if(c<30&&b==4&&a==2019){
		cout<<"Heisei";
		return 0;
	}
	cout<<"TBD";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}

template <class T> T nCr(int n, int r) {
    if (r > n)
        return 0;
    if (r * 2 > n)
        r = n - r;
    if (r == 0)
        return 1;
    T ans = n;
    for (int i = 2; i <= r; i++) {
        ans *= (T)(n - i + 1);
        ans /= (T)i;
    }
    return ans;
}

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

    int N;
    cin >> N;
    vector<string> S(N);
    for (auto &&i : S) {
        cin >> i;
    }

    SORT(S);
    vector<int> cnt(5);
    for (auto &&i : S) {
        if (i[0] == 'M')
            cnt[0]++;
        if (i[0] == 'A')
            cnt[1]++;
        if (i[0] == 'R')
            cnt[2]++;
        if (i[0] == 'C')
            cnt[3]++;
        if (i[0] == 'H')
            cnt[4]++;
    }
    ll ans = 0;
    REP(bit, (1 << 5)) {
        int bcnt = 0;
        vector<int> a;
        REP(i, 5) {
            if (bit & (1 << i)) {
                bcnt++;
                a.emplace_back(i);
            }
        }
        if (bcnt == 3) {
            ans += (ll)cnt[a[0]] * cnt[a[1]] * cnt[a[2]];
        }
    }

    std::cout << ans << '\n';

    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  vector<ll> h(n);
  rep (i, n) {
    cin>>h.at(i);
  }
  bool ans=true;
  
  rep (i, n-1) {
    if(h.at(n-1-i)<h.at(n-i-2)-1) {
      ans = false;
      break;
    }
    else if(h.at(n-i-1) == h.at(n-i-2)-1){
      h.at(n-i-2)--;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> x(n);
    rep(i,n) cin>>x[i];
    auto X=x;
    sort(x.begin(),x.end());
    rep(i,n){
        auto itr=lower_bound(x.begin(),x.end(),X[i]);
        int k=itr-x.begin();
        if(k>=n/2)cout<<x[n/2-1]<<endl;
        else cout<<x[n/2]<<endl;
    }
}

Measured memory_bytes: 3712
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    v = []
    for _ in range(5):
        v.append(int(input()))
    k = int(input())
    v.sort()

    if abs(v[0] - v[-1]) > k:
        print(":(")
    else:
        print("Yay!")




if __name__ == '__main__':
    main()


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

int main(){
      int n;cin >> n;
      int sum = 0;
      int maxx = 0;
      for(int i = 0;i < n;i++){
            int l;cin >> l;
            if(l > maxx)maxx = l;
            sum += l;
      }
      if(maxx < sum - maxx)cout << "Yes";
      else cout << "No";
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    int r=0;
    for(int i=0;i<n;++i){
      a[i]=sc.nextInt();
      while(a[i]%2==0){
        r++;
        a[i]/=2;
      }
    }
    System.out.println(r);
    
  }
}

Measured memory_bytes: 35044
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
 
ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
int main(){
    ll n,k;cin>>n>>k;
  	
  	if(2*k>n+1){
		cout<<-1<<endl;
    }else{
      	if(n%2==1){
          ll ans[n+1][3];
          rep(i,k,k+n-1){
              ans[i-k+1][0]=i;
            	cout<<ans[i-k+1][0]<<' ';
              if(i<=(n+1)/2+k-1){
					ans[i-k+1][1]=i+n+(n/2);
                	ans[i-k+1][2]=(k+2*n)+2*(i-k);
              }else{
					ans[i-k+1][1]=i+(n/2);
                	ans[i-k+1][2]=(k+2*n+1)+2*(i-(n+1)/2-k);
              }
               cout<<ans[i-k+1][1]<<' ';
             cout<<ans[i-k+1][2]<<endl;
          }
        }else{
		 ll ans[n+1][3];
          rep(i,k,n+k-1){
              ans[i-k+1][0]=i;
              cout<<ans[i-k+1][0]<<' ';
              if(i-k<n/2){
					ans[i-k+1][1]=i+n+(n/2);
                	ans[i-k+1][2]=(k+2*n)+2*(i-k);
              }else{
					ans[i-k+1][1]=i+(n/2);
               		ans[i-k+1][2]=(k+2*n+1)+2*(i-(k+(n/2)));
              }
              cout<<ans[i-k+1][1]<<' ';
              cout<<ans[i-k+1][2]<<endl;
          }
        }
      
    }
                        
                
		
    
    return 0;
}

Measured memory_bytes: 4608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	d := NewDsu(n)
	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		d.Merge(a, b)
	}
	g := d.Groups()
	var ans int
	for i := 0; i < n; i++ {
		if g[i] == nil {
			continue
		}
		if len(g[i]) > 0 {
			ans++
		}
	}
	fmt.Fprintln(writer, ans-1)
}

// Dsu Data structures and algorithms for disjoint set union problems
type Dsu struct {
	n            int
	parentOrSize []int
}

// NewDsu Constructor
func NewDsu(n int) *Dsu {
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = -1
	}
	return &Dsu{parentOrSize: p, n: n}
}

// Merge adds an edge (a, b).
func (d *Dsu) Merge(a, b int) int {
	x := d.Leader(a)
	y := d.Leader(b)
	if x == y {
		return x
	}
	if d.parentOrSize[x] > d.parentOrSize[y] {
		x, y = y, x
	}
	d.parentOrSize[x] += d.parentOrSize[y]
	d.parentOrSize[y] = x
	return x
}

// Same returns whether the vertices a and b are in the same connected component.
func (d *Dsu) Same(a, b int) bool {
	return d.Leader(a) == d.Leader(b)
}

// Leader returns the representative of the connected component that contains the vertex a.
func (d *Dsu) Leader(a int) int {
	if d.parentOrSize[a] < 0 {
		return a
	}
	d.parentOrSize[a] = d.Leader(d.parentOrSize[a])
	return d.parentOrSize[a]
}

// Size returns the size of the connected component that contains the vertex a.
func (d *Dsu) Size(a int) int {
	return -d.parentOrSize[d.Leader(a)]
}

// Groups divides the graph into connected components and returns the list of them.
func (d *Dsu) Groups() [][]int {
	result := make([][]int, d.n)
	for i := 0; i < d.n; i++ {
		l := d.Leader(i)
		result[l] = append(result[l], i)
	}
	return result
}


Measured memory_bytes: 11288
#include<stdio.h>

int main(void){
	int a,b,c,n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a*a==b*b+c*c||
		   b*b==a*a+c*c||
		   c*c==a*a+b*b){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>

using namespace std;

int main()
{
  int ans;
  int a[5] ;
  for(int i=0; i < 5;i++)
  {
    cin >> a[i];
  }
   for(int i=0; i < 5;i++)
  {
    if(a[i] == 0)
    {
      ans = i+1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 3148
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	
	int n, d,m;
	cin >> n >> d;
	m = 1 + d * 2;
	int ans = 0;
	int t = 0;
	for (int i = 0; i < n; i++) {
		t++;
		if (t == m)ans++;
		t %= m;
		
	}
	if (t)ans++;
	cout << ans;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  rep(i, n+1) {
    if(i*(i+1)/2 < n) continue;
    int diff = i*(i+1)/2-n;
    rep(j, i+1) {
      if(j == 0 || j == diff) continue;
      cout << j << endk;
    }
    break;
  }
  return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int res = 0;
	int val;
	for (int i = 0; i < n; i++) {
		cin>>val;
		if (val == res + 1)
			res++;
	}
	cout<<(res == 0 ? -1 : (n - res));
}


Measured memory_bytes: 256
h, w, k = map(int, input().split())
mat = [input() for i in range(h)]
num = 0
ans = [[0]*w for _ in range(h)]
heights = [0]*h
for i in range(h):
    for j in range(w):
        if mat[i][j] == "#":
            heights[i] += 1
hs = []
for v in range(h):
    if heights[v] >= 1:
      hs.append(v)
for i in range(len(hs)):
    h1 = 0
    h2 = h-1
    if i >= 1:
        h1 = hs[i-1] + 1
    if i < len(hs)-1:
        h2 = hs[i]
    ws = []
    for j in range(h1, h2+1):
        for k in range(w):
            if mat[j][k] == "#":
                ws.append(k)
    ws.sort()
    for j in range(len(ws)):
        w1 = 0
        w2 = w-1
        if j >= 1:
            w1 = ws[j-1]+1
        if j < len(ws)-1:
            w2 = ws[j]
        num += 1
        for k in range(h1, h2+1):
            for l in range(w1, w2+1):
                ans[k][l] = num
for i in range(h):
    print(*ans[i])



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

int main() {
	int X, Y;
	cin >> X >> Y;
	int v = 0;
	int i = 0;
	int j = X;

	while (i != X) {
		if ((i*2+j*4) == Y) {
			v++;
		}
		i++;
		j--;
	}
	if ((i * 2 + j * 4) == Y) {
		v++;
	}
	
	
	
	if (v >= 1) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var b = new Dictionary<string, int>() { { "A", 0 }, { "B", 0 }, { "AB", 0 }, { "O", 0 } };
			string s = "";
			while ((s = Console.ReadLine()) != null)
			{
				b[s.Split(',')[1]]++;
			}
			Console.WriteLine(b["A"]);
			Console.WriteLine(b["B"]);
			Console.WriteLine(b["AB"]);
			Console.WriteLine(b["O"]);
		}
	}
}

Measured memory_bytes: 5616
import sys
input = sys.stdin.readline


def read():
    H, W = map(int, input().strip().split())
    A = []
    for i in range(H):
        a = list(input().strip())
        A.append(a)
    return H, W, A


def solve(H, W, A):
    is_skip_rows = [True for i in range(H)]
    is_skip_cols = [True for j in range(W)]
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                is_skip_rows[i] = False
                is_skip_cols[j] = False
    for i in range(H):
        if is_skip_rows[i]:
            continue
        line = []
        for j in range(W):
            if is_skip_cols[j]:
                continue
            line.append(A[i][j])
        print(''.join(line))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  ll N;
  string S1, S2;
  cin >> N >> S1 >> S2;
  ll res = 1;
  int x = 0, pre = -1;
  while (x<N) {
    if (S1[x]==S2[x]) {
      if (pre<0) res = 3;
      else if (pre==0) res = res*2%MOD;
      else res %= MOD;
      x++;
      pre = 0;
    }
    else {
      if (pre<0) res = 6;
      else if (pre==0) res = res*2%MOD;
      else res = res*3%MOD;
      x += 2;
      pre = 1;
    }
  }
  cout << res%MOD << endl;
  return 0;
}

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

int main(){
    int N, K,sum=0;
    cin >> N >> K;
    vector<int> l(N);
    for(int i = 0; i < N; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());
    for(int i = 0; i < K; i++){
        sum += l[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 504
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int H, W;
	cin >> H >> W;
	vector<string>S(H);
	rep(i, H)cin >> S[i];
	int dy[4] = { 1,0,-1,0 };
	int dx[4] = { 0,1,0,-1 };
	int ans = 0;
	vector<vector<bool>>seen(H, vector<bool>(W, false));
	rep(i, H)rep(j, W) {
		int b = 0, w = 0;
		queue<P>q;
		q.push(P(i, j));
		while (q.size()) {
			P p = q.front();
			q.pop();
			if (seen[p.first][p.second])continue;
			seen[p.first][p.second] = true;
			if (S[p.first][p.second] == '#')b++;
			else w++;
			rep(k, 4) {
				int nh = p.first + dx[k];
				int nw = p.second + dy[k];
				if (nh < 0 || nh >= H || nw < 0 || nw >= W)continue;
				if (S[p.first][p.second] == S[nh][nw])continue;
				q.push(P(nh, nw));
			}
		}
		ans += b * w;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3852
N = int(input().strip())
l = list(map(int, input().strip().split()))

sl = sorted(l, reverse = True)

A = []
B = []

for _ in range(len(l)):
  if _%2 == 0:
    A.append(sl[_])
  else:
    B.append(sl[_])

gap = sum(A) - sum(B)

print(gap)

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

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input){
        initialize(n_input, f_input, e_input);
    }
    void initialize(int n_input, Func f_input, T e_input){
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

int N, H[200000], A[200000];

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

    Segtree<int64_t> st(N+1, [](int64_t a, int64_t b){ return max(a, b); }, 0);
    for(int i=0; i<N; i++){
        st.update(H[i], st.between(0, H[i]-1) + A[i]);
    }
    cout << st.between(0, N) << endl;
    return 0;
}

Measured memory_bytes: 5888
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int n;
int w[200];

int main()
{
    int ans=1000000;
    cin>>n;
    for (int i=1; i<=n; ++i)
        cin>>w[i];
    for (int i=1; i<=n; ++i)
    {
        int ans1=0,ans2=0;
        for (int j=1; j<i; ++j)
            ans1+=w[j];
        for (int j=i; j<=n; ++j)
            ans2+=w[j];
        int ans3 = ans1-ans2;
        if (ans3<0) ans3*=-1;
        if (ans3<ans) ans = ans3;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class b{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int n = int.Parse(str[1]);
    int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    Array.Sort(num);
    int sum = 0;
    for(int i=0; i<n; i++){
      sum += num[i];
    }
    Console.WriteLine(sum);
  }
}


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

using namespace std;

int N, M, Q;
vector < int >a, b, c, d;
int ans;

void dfs(vector < int >A)
{
	if (A.size() == (size_t)N + 1) {
		int now = 0;
		for (int i = 0; i < Q; i++) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				now += d[i];
			}
		}
		ans = max(ans, now);
		return;
	}

	A.push_back(A.back());
	while (A.back() <= M) {
		dfs(A);
		A.back()++;
	}
}

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

	a = b = c = d = vector < int >(Q);

	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	dfs(vector < int >(1, 1));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

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

bool ans=false;
int sum=0;
size_t si=s.length();

rep(i,si){
    char t=s[i];
   int num=(int)t-48;
    sum+=num;
}

if(sum==0)ans=true;
else if(sum%9==0)ans=true;

if(ans)cout<<"Yes"<<endl;
else cout<<"No"<<endl;


return 0;
 }


Measured memory_bytes: 3768
N= int(input())
Harray = []
for i in range(N):
    Aarray = []
    A = int(input())
    for j in range(A):
        xy = list(map(int,input().split()))
        Aarray.append(xy)
    Harray.append(Aarray)


count = []
for i in range(2**N):
    honest = [0 for i in range(N)]
    c = 0
    for j in range(N):
        if (i >> j) & 1 == 1:
            honest[j] = 1
    for k in range(N):
        if honest[k] == 1:
            ar = Harray[k]
            for l in ar:
                if honest[l[0]-1] != l[1]:
                    c = 1
    if c == 0:
        count.append(honest.count(1))
print(max(count))

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 10000
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a[100000];
int ans[100010];

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans[a[i]] = i + 1;
	}
	for (int i = 1; i < n; i++)cout << ans[i] << " ";
	cout << ans[n] << endl;
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String t = in.next();

        if (s.length() < t.length()) {
            System.out.println("UNRESTORABLE");
            return;
        }

        for (int i = s.length() - t.length(); i >= 0; i--) {
            String sub = s.substring(i, i + t.length());
            if (!canSame(sub, t)) {
                continue;
            }
            for (int j = 0; j < s.length(); j++) {
                if (j >= i && j < i + t.length()) {
                    System.out.print(t.charAt(j - i));
                } else if (s.charAt(j) == '?') {
                    System.out.print('a');
                } else {
                    System.out.print(s.charAt(j));
                }
            }
            return;
        }

        System.out.println("UNRESTORABLE");
    }

    static boolean canSame(String s, String t) {
        for (int i = 0; i < t.length(); i++) {
            if (s.charAt(i) == '?') {
                continue;
            }
            if (s.charAt(i) != t.charAt(i)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 35512
from itertools import combinations
N = int(input())
L = list(map(int, input().split()))
ans = 0
for l in combinations(L, 3):
    a = l[0]
    b = l[1]
    c = l[2]
    if a == b or b == c or c == a:
        continue
    if a + b > c and b + c > a and c + a > b:
        ans += 1
print(ans)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k, a[100000], d[100000];
    cin >> n >> k;
    d[0] = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i > 0) d[i] = d[i - 1] + a[i] - a[i - 1];
    }
    int ans = 3 * int(1e8);
    for (int i = 0; i < n - k + 1; ++i) {
        ans = min(ans, min(abs(a[i + k - 1]), abs(a[i])) + d[i + k - 1] - d[i]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
using namespace std;
const int N=4040;
int i,j,k,n,m,A,B;
int d[N];
char s[N],ss[10];
int main() {
	scanf("%d%d",&A,&B);
	if (A<=B) {
		puts("Impossible");
		fflush(stdout);
		return 0;
	}
	n=A+B;
	for (i=0;i<n;i++) {
		if (!m) d[++m]=i;
		else {
			printf("? %d %d\n",d[m],i);
			fflush(stdout);
			scanf("%s",ss);
			if (ss[0]=='Y') d[++m]=i;
			else m--;
		}
	}
	for (i=0;i<n;i++) {
		if (d[m]!=i) {
			printf("? %d %d\n",d[m],i);
			fflush(stdout);
			scanf("%s",ss);
			if (ss[0]=='Y') s[i]='1';
			else s[i]='0';
		}
		else s[i]='1';
	}
	printf("! %s\n",s);
	fflush(stdout);
}

Measured memory_bytes: 704
#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__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int a, b;
    cin >> a >> b;
    if(0<a && 0<b){
        cout << "Positive" << endl;
        return 0;
    }
    if((a<0 && 0<b) || (b<0 && 0<a) || (a==0 || b==0)){
        cout << "Zero" << endl;
        return 0;
    }
    if(a%2 == b%2){
        cout << "Negative" << endl;
    } else {
        cout << "Positive" << endl;
    }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict
s = input()
L = len(s)
N = int(s)
ls = [3, 5, 7]
dic = defaultdict(int)
def dfs(s):
  if len(s)<L:
    return dfs(s+'3')+dfs(s+'5')+dfs(s+'7')+dfs('0'+s)
  if (not '3' in s) or(not '5' in s) or(not '7' in s):
    return 0
  if int(s)<=N and dic[s]==0:
    dic[s]=1
    return 1
  else:
    return 0
print(dfs(''))

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

long long func(long long tmp) {
    if (tmp == 1) {
        return 1;
    }
    return 2 * func(tmp / 2) + 1;
}

void solve(long long H) { printf("%lld\n", func(H)); }

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long H;
    scanf("%lld", &H);
    solve(H);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=300050;
//ここまでテンプレ
int main(){
	ll N,K;
	cin>>N>>K;
	vll P,M;
	for(int i=0;i<N;i++){
		ll x;
		cin>>x;
		if(x<0)
			M.pb(x);
		else
			P.pb(x);
	}
	sort(M.begin(),M.end(),greater<ll>());
	sort(P.begin(),P.end());
	/*
	for(int i=1;i<M.size();i++){
		M[i]+=M[i-1];
	}
	for(int i=1;i<P.size();i++){
		P[i]+=P[i-1];
	}*/
	ll ans=INFLL;
	if(M.size()>=K)
		ans=min(ans,-M[K-1]);
	if(P.size()>=K)
		ans=min(ans,P[K-1]);
	for(int i=0;i<M.size() && i<=K;i++){
		if(P.size()>=K-i-1 && K-i-2>=0)
			ans=min(ans,-M[i]+2*P[K-i-2]);
	}
	for(int i=0;i<P.size() && i<=K;i++){
		if(M.size()>=K-i-1 && K-i-2>=0)
			ans=min(ans,P[i]-2*M[K-i-2]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1656
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

import numpy as np

N,M,L = map(int,readline().split())
ABCPST = np.array(read().split(),np.int64)
ABC = ABCPST[:M+M+M]
A = ABC[::3]; B = ABC[1::3]; C = ABC[2::3]
ST = ABCPST[M+M+M+1:]
S = ST[::2]; T = ST[1::2]

# とりあえず、補給抜きにして最短距離を求める
graph = csr_matrix((C,(A,B)),(N+1,N+1))
dist_mat = floyd_warshall(graph,directed=False)

# 補給なしに行ける移動を1手とする

graph2 = np.full((N+1,N+1),np.inf)
np.fill_diagonal(graph2,0)
graph2[dist_mat<=L+.5] = 1

dist_mat2 = floyd_warshall(graph2,directed=False)

dist_mat2[dist_mat2 == np.inf] = 0
dist_mat2 = (dist_mat2+.5).astype(int)

x = dist_mat2[S,T] - 1

print('\n'.join(x.astype(str)))

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

int main(){
  int x;
  cin>>x;
  if(x%10==7){
  cout<<"Yes"<<endl;
  return 0;
  }
  if((x%100)-(x%10)==70){
  cout<<"Yes"<<endl;
  return 0;
  }
  if(x-(x%100)==700){
  cout<<"Yes"<<endl;
  return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3632