akhauriyash/Code-Regression huggingface dataset:
s = gets.chomp
len = s.length
memo = Hash.new
len.times do |i|
  ss = s[i]
  memo[ss] = s.count(ss)
end
#p memo

max = 0
memo.each do |key,val|
  if val > max then
    max = val
  end
end

max_s = Array.new
memo.each do |key,val|
  #if max == val then
    max_s.push(key)
  #end
end
#p max_s

if max == len then
  puts "0"
  exit
end

kekka = Array.new
max_s.each do |c|
  len2 = len
  cnt = 0
  loop = true
  s2 = s.dup
  while loop do
    ss = ""
    (len2-1).times do |i|
      if s2[i]==c || s2[i+1]==c then
        ss += c
      else
        ss += s2[i]
      end
    end
    #puts "#{len2} #{c} #{ss}"
    cnt += 1
    len2 -= 1
    if len2==0 then
      loop = false
    end
    if ss.count(c)==ss.length then
      loop = false
    end
    s2 = ss
  end
  #puts "--> #{cnt}"
  kekka.push(cnt)
end

puts kekka.min

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

bool is_poss(int a,int b, int c, int m, int n, int p){
    return (a*(1<<m) < b*(1<<n)) &&  (b*(1<<n) < c*(1<<p));
}

void solve(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++)
            for(int x=0;x<=k;x++){
                if(i+j+x<=k && is_poss(a,b,c,i,j,x)){
                    cout<<"Yes\n";
                    return;
                }
            }
    cout<<"No\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll A,B,C,D;cin>>A>>B>>C>>D;
    cout<<max(A*B,C*D)<<endl;
}

Measured memory_bytes: 3588
'''input
4
10 30 40 20
'''

n=int(input())
arr=list(map(int,input().split()))
dp=[0]*len(arr)
for i in range(1,n):
	dp[i]=dp[i-1]+abs(arr[i]-arr[i-1])
	if(i>1):
		a=dp[i-2]+abs(arr[i]-arr[i-2])
		dp[i]=min(dp[i],a)
print(dp[n-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a[51],b[51],c[51],d[51];
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int j=0;j<m;j++){
		cin>>c[j]>>d[j];
	}
	for(int i=0;i<n;i++){
		int dis[51];
		int cou[51];
		for(int j=0;j<m;j++){
			dis[j]=abs(a[i]-c[j])+abs(b[i]-d[j]);
			cou[j]=j+1;
		}
		for(int j=0;j<m;j++){
			for(int k=0;k<m-1-j;k++){
				if(dis[k]>dis[k+1]){
					swap(dis[k],dis[k+1]);
					swap(cou[k],cou[k+1]);
				}
			}
		}
		cout<<cou[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

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


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <math.h>
using namespace std;


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector <int> > v2i;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
const int N = 1e5 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

int main()
{   
    int rem  = 10;
    int pos = -1;
    std::vector<int> v(5);
    for (int i = 0; i < 5; ++i)
    {
    	cin>>v[i];
    	if(v[i]%10<rem&&v[i]%10!=0){
    		pos = i;
    		rem = v[i]%10;
    	}
    }

    int ans=0;
    for (int i = 0; i < 5; ++i)
    {
    	if(v[i]%10!=0&&i!=pos){
    		ans+=v[i]+10-v[i]%10;
    		 
    	}
    	else if (v[i]%10==0&&i!=pos){
    		ans += v[i];
    	    	}
    }

    if (pos!=-1)
    {
    	ans+= v[pos];
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B,C;

signed main(){
	cin>>A>>B>>C;
	for(int i=0;i<1000000;i++){
		if(A%2==1||B%2==1||C%2==1){
			cout<<i<<endl;
			return 0;
		}
		int a=B/2+C/2;
		int b=A/2+C/2;
		int c=A/2+B/2;
		A=a,B=b,C=c;
	}
	cout<<-1<<endl;
	return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i64 L, R;
    cin >> L >> R;
    i64 ans = INF;
    for (i64 i = L; i < L + 2019; i++) {
        for (i64 j = i + 1; j <= R; j++) {
            if (ans > (i * j) % 2019)
                ans = (i * j) % 2019;
            if (ans == 0) break;
        }
        if (ans == 0) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 N, D;
  std::cin >> N >> D;
  std::cout << tools::ceil(N, 2 * D + 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <bool> sosu(1000010,true);
void a(){
	sosu[1] = false;
	for(int i = 2; i < 1000010; i++){
		if(sosu[i] == true)
			for(int j = 2; i*j < 1000010; j++){
				sosu[i * j] = false;
			}
	}
}

int main(){
	int n,x;
	a();
	while(cin >> n >> x, n){
		bool dp[1000010] = {0};
		dp[0] = true;
		int v[n];
		for(int i = 0; i < n; i++)
			cin >> v[i];
		sort(v,v + n);
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 1000010; j++){
				if(dp[j] == true && j + v[i] < 1000010)
					dp[j + v[i]] = true;
					
			}
		}
		int judge = true;
		for(int i = x; i != 1; i--)
			if(dp[i] == true && sosu[i] == true){
				cout << i << endl;
				judge = false;
				break;
			}
		if(judge)
			cout << "NA" << endl;
	}
	return 0;
}

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

typedef pair<int, int> Pii;

int main() {
  int M, T, P, R;
  while ( cin >> M >> T >> P >> R, M ) {
    vector<int> cnt(T, 0);
    vector<vector<int> > solved(T, vector<int>(P, 0));    
    vector<int> times(T, M+1);
    vector<vector<int> > pena(T, vector<int>(P, 0));    
    while ( R-- ) {
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      t--; p--;
      if ( !j ) {
	if ( solved[t][p] ) continue;
	solved[t][p] = 1;
	times[t] += m;
	times[t] += pena[t][p]*20;	
	cnt[t]++;	
      } else if ( !solved[t][p] ) {
	pena[t][p]++;
      }
    }

    vector<Pii> ps[P+1];    
    for ( int i = 0; i < T; i++ ) {
      ps[cnt[i]].push_back(Pii(times[i], -i));      
    }

    int cnt_t = 0;
    for ( int i = P; i >= 0; i-- ) {
      if ( !ps[i].size() ) continue;
      sort(ps[i].begin(), ps[i].end());
      for ( int j = 0; j < (int)ps[i].size(); j++ ) {
	if ( !cnt_t ) cout << -ps[i][j].second+1;
	else if ( j && ps[i][j].first == ps[i][j-1].first ) {
	  cout << '=' << -ps[i][j].second+1;
	} else {
	  cout << "," << -ps[i][j].second+1;	  
	}
	cnt_t++;
      }
    }
    
    cout << endl;
  }

  return 0;
}



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

int main(){
 int n, k;
 int keiji=1;
 cin >> n >> k;
 
 for(int i=0;i<n;i++){
   if(keiji*2<keiji+k) keiji*=2;
   else keiji+=k;
 }
 
  cout << keiji << endl;
}

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

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

    bool ans = false;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            int v = i * j + (n - i) * (m - j);
            if (v == k) {
                ans = true;
                break;
            }
        }
    }

    cout << (ans ? "Yes" : "No") << 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;
int main(){
  int a,b;
  cin>>a>>b;
  if(a%2==1 && b%2==1){
    cout<<"Odd"<<endl;
  }else{
    cout<<"Even"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
int a[114514];
signed main(){
	ic(n)ic(k)
	c((n-2)/(k-1)+1)
}	

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<lint> A(N, 0ll), B(N, 0ll), C(N, 0ll);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    lint sumA = 0, sumB = 0;
    rep(i, N) {
        sumA += A[i];
        sumB += B[i];
    }
    rep(i, N) C[i] = A[i] - B[i];
    sort(all(C));
    dump(C);
    if (sumB < sumA) {
        cout << "No" << endl;
        return 0;
    }

    rep(i, N) {
        if (C[i] < 0 and C[i] % 2 != 0) { C[i]++; }
    }

    lint cnt = 0;
    rep(i, N) {
        if (C[i] > 0) { cnt += C[i]; }
    }
    rep(i, N) {
        if (C[i] < 0) { cnt += C[i] / 2; }
    }
    cout << (cnt <= 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 512
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end
# S = gets_s

h, w = gets_i_list

puts "#" * (w + 2)
h.times do
  s = gets_s
  puts "#" + s + "#"
end
puts "#" * (w + 2)


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
void solve(void)
{
    int n, a;
    cin >> n >> a;
    if (a >= n % 500)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3572
def move(dice, order):
  if order == "E":
    temp = dice[0]
    dice[0] = dice[3]
    dice[3] = dice[5]
    dice[5] = dice[2]
    dice[2] = temp
  elif order == "N":
    temp = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = temp
  elif order == "S":
    temp = dice[0]
    dice[0] = dice[4]
    dice[4] = dice[5]
    dice[5] = dice[1]
    dice[1] = temp
  elif order == "W":
    temp = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = temp
  else:
    pass
  return dice

def roll(dice):
  temp = dice[1]
  dice[1] = dice[2]
  dice[2] = dice[4]
  dice[4] = dice[3]
  dice[3] = temp
  return dice

dice = list(map(int, input().split()))
q = int(input())
for i in range(q):
  up, front = map(int, input().split())
  cnt = 0
  while (dice[0] != up and cnt <= 3):
    dice = move(dice, "E")
    cnt += 1
  while dice[0] != up:
    dice = move(dice, "N")
  while dice[1] != front:
    dice = roll(dice)
  print(dice[2])


Measured memory_bytes: 5604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

// 

public class ABC117_C // ←Class名変更！！
{
    public static void Main()
    {
        var n = Ria();
        var comaN = n[0];
        var xPointM = n[1];
        var x = Ria();

        if (xPointM <= comaN)
        {
            WriteLine($"0");
            return;
        }

        Array.Sort(x);
        var dests = new int[xPointM - 1];
        for (int i = 0; i < xPointM - 1; i++)
        {
            dests[i] = Abs(x[i] - x[i + 1]);
        }

        Array.Sort(dests);

        var moveCount = xPointM - comaN;
        var moveVal = dests.ToList().Take(moveCount).Sum();

        WriteLine($"{moveVal}");
        return;

    } // Main

    public static string Rs() { return ReadLine(); }
    public static char Rc() { var c = ReadLine(); return c[0]; }    //最初の1文字だけ返す
    public static int Ri() { return int.Parse(ReadLine()); }
    public static long Rl() { return long.Parse(ReadLine()); }
    public static char[] Rca() { return ReadLine().ToCharArray(); }
    public static int[] Ria() { return Array.ConvertAll(ReadLine().Split(' '), int.Parse); }
    public static long[] Rla() { return Array.ConvertAll(ReadLine().Split(' '), long.Parse); }
} // Class


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

int main(){
  int N, M, X;
  cin>>N>>M>>X;
  int CA[15][15] = {};
  int b;
  vector<int> ans;
  for(int i=0; i<N; i++)for(int j=0; j<=M; j++){
    cin>>CA[i][j];
  }

  //cout<<"end read"<<endl;

  int bits;
  long long CA_sum[15];
  for(bits=1; bits<(1<<N); bits++){
    //bit全探索
    for(int i=0; i<15; i++)CA_sum[i] = 0;
    
    //cout<<"startBits"<<bits<<endl;

    for(int c=0; c<N; c++){
      //各本について
      if(bits & 1<<c){
        //買う時
        //cout<<"buy"<<c;
        for(int a=0; a<=M; a++){
          //代金と理解度足す
          CA_sum[a] += CA[c][a];
        }
      }
    }

    /*
    cout<<endl;
    for(int i=0; i<=M; i++){
      cout<<CA_sum[i]<<",";
    }cout<<endl;
    //*/

    
    int ok = 1;
    for(int i=1; i<=M; i++){
      //cout<<CA_sum[i];
      if(CA_sum[i] >= X){
        //cout<<"ok"<<endl;
        ok *= 1;
      }else{
        //cout<<"no"<<endl;
        ok *= 0;
      }
    }

    if(ok==1){
      ans.push_back(CA_sum[0]);
    }
    //*/
  }

  long long lastans;
  if(ans.size()==0){
    lastans = -1;
  }else{
    lastans = *min_element(ans.begin(), ans.end());
  }

  cout<<lastans<<endl;
}

Measured memory_bytes: 3640
if __name__ == "__main__":
    N = int(input())
    a_str = list(map(int, input().split(" ")))

    min_a = min(a_str)
    max_a = max(a_str)

    min = float("inf")
    ans = 0
    for i in range(min_a, max_a):

        temp = sum(list(map(lambda x: (x - i)**2, a_str)))
        if min > temp:
            min = temp
            ans = temp
    print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
    long long sum=0;
	int a[n];
	int dp[n];
	for(int i = 0;i<n;i++)
	cin>>a[i];
	dp[0]=0,dp[1]=abs(a[1]-a[0]);
	for(int i = 2; i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9




int main(){
  ll H, W;
  cin >> H >> W;

  ll ans;

  if(H % 3 == 0){
    ans = 0;
  }
  else{
    ans = (H/3+1)*W - H/3*W;
  }
  if(W%3==0){
    ans = 0;
  }
  else{
    ans = min(ans, (ll)(W/3+1)*H-W/3*H);
  }
  vector<ll> s(3);
  FOR(i, 1, W){
    s[0] = i*H;
    s[1] = (W-i)*(H/2);
    s[2] = (W-i)*(H/2+H%2);
    ll maxs = max(s[0], s[2]);
    ll mins = min(s[0], s[1]);
    ans = min(ans, maxs -mins);
  }
  FOR(i, 1, H){
    s[0] = i*W;
    s[1] = (H-i)*(W/2);
    s[2] = (H-i)*(W/2+W%2);
    ll maxs = max(s[0], s[2]);
    ll mins = min(s[0], s[1]);
    ans = min(ans, maxs -mins);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
def N(n):
    return (n+1)*(n+2)*(n+3)/6
for n in sys.stdin:
    n = int(n)
    if n > 2000:
        n = 4000 - n
    if n < 1001:
        print N(n)
    else:
        m = n - 1000
        print N(n) - (N(2*m) - m - 1)/2

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

int main(){
    int N=0;
    cin >> N;
    int a[100]={};
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            a[i*j]++;
        }
    }
    if(a[N]==0)cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <bits/stdc++.h>
    #define rep(i, n) for (int i = 0; i < (n); ++i)
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> P;
     
    #define pb push_back
    #define eb emplace_back
    #define fi first
    #define se second
    #define bg begin()
    #define ed end()
    #define all(x) x.bg, x.ed
    #ifdef LOCAL
    #define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
    #else
    #define dmp(x) void(0)
    #endif
     
    template <class t, class u>
    void chmax(t &a, u b)
    {
      if (a < b)
        a = b;
    }
    template <class t, class u>
    void chmin(t &a, u b)
    {
      if (b < a)
        a = b;
    }
    const int mod = 1000000007;
    struct mint
    {
      ll x; // typedef long long ll;
      mint(ll x = 0) : x((x % mod + mod) % mod) {}
      mint &operator+=(const mint a)
      {
        if ((x += a.x) >= mod)
          x -= mod;
        return *this;
      }
      mint &operator-=(const mint a)
      {
        if ((x += mod - a.x) >= mod)
          x -= mod;
        return *this;
      }
      mint &operator*=(const mint a)
      {
        (x *= a.x) %= mod;
        return *this;
      }
      mint operator+(const mint a) const
      {
        mint res(*this);
        return res += a;
      }
      mint operator-(const mint a) const
      {
        mint res(*this);
        return res -= a;
      }
      mint operator*(const mint a) const
      {
        mint res(*this);
        return res *= a;
      }
      mint pow(ll t) const
      {
        if (!t)
          return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
          a *= *this;
        return a;
      }
     
      // for prime mod
      mint inv() const
      {
        return pow(mod - 2);
      }
      mint &operator/=(const mint a)
      {
        return (*this) *= a.inv();
      }
      mint operator/(const mint a) const
      {
        mint res(*this);
        return res /= a;
      }
    };
    struct combination
    {
      vector<mint> fact, ifact;
      combination(int n) : fact(n + 1), ifact(n + 1)
      {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
          fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
          ifact[i - 1] = ifact[i] * i;
      }
      mint operator()(int n, int k)
      {
        if (k < 0 || k > n)
          return 0;
        return fact[n] * ifact[k] * ifact[n - k];
      }
    };
     
    template <class t>
    using vc = vector<t>;
    template <class t>
    using vvc = vc<vc<t>>;
     
    using vi = vc<int>;
    int gcd(int a, int b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
    int lcm(int a, int b)
    {
      return (a * b) / gcd(a, b);
    }
     
    int main()
    {
      int n, m;
      cin >> n >> m;
      if(n<m){
      rep(i,m){
      cout<<n;
      }
      }else if(n == m){
		rep(i,n){
        cout<<n;
        }      
      }else{
      rep(i,n){
      cout<<m;
      }
      }
    }

Measured memory_bytes: 256
n = int(input())
f = []
p = []
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    f.append(tmp)
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    p.append(tmp)

ans = -10 ** 10

for i in range(1, 2**10):
    tmp = 0
    for j in range(n):
        cnt = 0
        for z in range(10):
            if ((i>>z)%2 == 1 and f[j][z] == 1):
                cnt += 1
        tmp += p[j][cnt]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 3064
use std::io::stdin;
fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().parse::<f64>().unwrap();

    println!("{}", solve(n));
}

fn solve(n: f64) -> String {
    let mut rounded = (n / 1.08).round();
    if n == (rounded * 1.08).floor(){
    } else if n == ((rounded + 1.0) * 1.08).floor(){
        rounded += 1.0;
    } else if n == ((rounded - 1.0) * 1.08).floor(){
        rounded -= 1.0;
    } else {
        return ":(".to_string()
    }
    rounded.to_string()
}

Measured memory_bytes: 4352
#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 inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,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)
                                  #define VI vector<int>
                                        using namespace std;


int gcd(int a,int b){
	if(a<b) return gcd(b,a);
	if(b==0) return a;
	if(a%b==0) return b;
	return gcd(b,a%b);
}
set<string >se;
           signed main(){
               int n,m;
 			cin>>n;
           	int ans=-inf*10000ll;
           	int imamin=inf*10000ll;
           	for(int i=0;i<n;i++){
           		cin>>m;
           		ans=max(ans,m-imamin);
           		imamin=min(imamin,m);
           	}
           	
           	cout<<ans<<endl;
           }
             

Measured memory_bytes: 3084
S = input()
if 1 <= int(S[0:2]) <= 12:
    if 1 <= int(S[2:4]) <= 12:
        print ("AMBIGUOUS")
    else:
        print ("MMYY")
else:
    if 1 <= int(S[2:4]) <= 12:
        print ("YYMM")
    else:
        print ("NA")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define mp make_pair
#define sqr(x) (x)*(x)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=100007;
const ll inf=1<<29;
int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int a[maxn];
char s[maxn];
int pre[maxn][4];
int main(){
    int n=read();
    scanf("%s",s+1);
    for(int i=1;i<=n;i++){
        if(s[i]=='R') a[i]=1;
        else if(s[i]=='G') a[i]=2;
        else if(s[i]=='B') a[i]=3;
        pre[i][a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int k=1;k<=3;k++)
        pre[i][k]+=pre[i-1][k];
    }
    ll sum=0;
    for(int i=1;i<=n;i++){
        for(int k=i+2;k<=n;k++){
            int x=a[i],y=a[k];
            if(x^y){
                int z=6-x-y;
                sum+=pre[k][z]-pre[i][z];
                if((k-i)%2==0){
                    if(a[(k+i)/2]==z) sum--;
                }
            }
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string n;
  	cin >> n;
  	int a = n.size() - 1;
  	if((n.at(a)=='0')||(n.at(a)=='1')||(n.at(a)=='6')||(n.at(a)=='8')) cout << "pon" << endl;
  	else if(n.at(a) == '3') cout << "bon" << endl;
  	else if((n.at(a)=='2')||(n.at(a)=='4')||(n.at(a)=='5')||(n.at(a)=='7')||(n.at(a)=='9'))cout << "hon" << endl;
}

Measured memory_bytes: 3600
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

def main():
    n, m = map(int, input().split())

    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        uf.unite(a-1, b-1)
    roots = uf.roots()
    cnt = []
    for r in roots:
        cnt.append(uf.size(r))
    print(max(cnt))

if __name__ == '__main__':
    main()


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> mat(n, vector<int>(m,0));
    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            cin >> mat.at(i).at(j);
        }
    }
    vector<int> vec(m);
    for (int i=0; i<m; i++){
        cin >> vec.at(i);
    }

    for (int i=0; i<n; i++){
        int sum=0;
        for (int j=0; j<m; j++){
            sum+=mat.at(i).at(j) * vec.at(j);
        }
        cout << sum << endl;
    }

}


Measured memory_bytes: 3156
#include <iostream>
using namespace std;
int main(){
    int n,k;
    cin>>n;
    cin>>k;
    int ans=0;
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        if(h>=k){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long int x;
    cin >> x;

    long long int ans = 2 * (x / 11);
    x %= 11;

    if (x > 0 && x <= 6)
        ++ ans;
    else if (x > 6)
        ans += 2;

    cout << ans << '\n';
    return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> Graph(N);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		Graph[A - 1].push_back(B - 1);
		Graph[B - 1].push_back(A - 1);
	}
	queue<int> Q;
	vector<int> Visited(N, 0);
	Q.push(0);
	Visited[0] = 1;
	int MAX = 0, start = 0, now = 1;
	while (start < N) {
		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			for (int u : Graph[v]) {
				if (Visited[u]) continue;
				Visited[u] = 1;
				now++;
				Q.push(u);
			}
		}
		MAX = max(MAX, now);
		while (start < N && Visited[start] == 1) start++;
		if (start == N) break;
		Q.push(start);
		Visited[start] = 1;
		now = 1;
	}
	cout << MAX << endl;
}


Measured memory_bytes: 15512
#include<cstdio>
using namespace std;
int main(void){
	int n;
	int t,a;
	int h;
	int i;
	int x,ans,MIN;
	int sum;
	scanf("%d%d%d",&n,&t,&a);
	MIN=1000000000;
	ans=0;
	for(i=1;i<=n;i++){
		scanf("%d",&h);
		x=t*1000-h*6;
		sum=x-a*1000;
		if(sum<0)	sum*=-1;
		if(MIN>sum){
			MIN=sum;
			ans=i;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

float T,X;

int main(){
    cin>>T>>X;
    out(T/X);
}


Measured memory_bytes: 256
A,B,C=map(int,input().split())
num_list=sorted([A,B,C])
cnt=0
cnt+=num_list[2]-num_list[1]
num_list[0]+=cnt
num_list[1]+=cnt
if (num_list[1]-num_list[0])%2==0:
    c=int((num_list[1]-num_list[0])/2)
else:
    c=int((num_list[1]-num_list[0])/2)+1
cnt+=c
num_list[0]+=2*c
if num_list[0]-num_list[1]==1:
    cnt+=1
    num_list[1]+=1
    num_list[2]+=1
else:
    cnt+=0
    
print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define ii pair <int, int>
#define f first
#define s second
#define INF 1e9
#define MOD 1000000007
#define MAXN 1000
#define debug(x) cerr << #x << " = " << x << endl
#define debug_arr(x, tam) cerr << #x << " = "; for (int i=0;i<tam;i++) cout << x[i] << " "; printf("\n")
using namespace std;

int arr[MAXN];

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

	int res = 0;
	int num;
	for (int i=0; i<n; i++){
		scanf("%d", &num);
		while (num % 2 == 0){
			res++;
			num /= 2;
		}
	}
	printf("%d\n", res);

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();


        for(int i = 1; i < s.length(); i++) {
            if (s.charAt(i - 1) == s.charAt(i)) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");

    }
}

Measured memory_bytes: 23892
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

count = 0
(0..a).each do |ia|
  (0..b).each do |ib|
    d = x - ia * 500 - ib * 100
    count+=1 if d % 50 == 0 && (0..c)===(d / 50)
  end
end

puts count

Measured memory_bytes: 1788
N = int(input())
S = str(input())
W=[0] * N
E=[0] * N

for i in range(1, N):
    if S[i-1] == "W":
        W[i]=W[i-1]+1
    else:
        W[i]=W[i-1]
for i in range(N-2, -1, -1):
    if S[i+1] == "E":
        E[i]=E[i+1]+1
    else:
        E[i]=E[i+1]

tmp=W[0]+E[0]
for i in range(1, N):
    if tmp > W[i]+E[i]:
        tmp = W[i]+E[i]

print(tmp)

Measured memory_bytes: 17572
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    boolean flag=true;
    long a=scan.nextLong();
    long b=scan.nextLong();
    long per=a%b;
    if(per>Math.abs(per-b)){
      per=Math.abs(per-b);
    }
    System.out.println(per);
  }
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;

class Program {
    static void Main( string[] args )
    {
        List<string> spades = new List<string>( 13 );

        for ( int i = 1; i < 14; ++i ) {
            spades.Add( i.ToString() );
        }

        List<string> hearts = new List<string>( spades );
        List<string> clubs = new List<string>( spades );
        List<string> diamonds = new List<string>( spades );

        int n = int.Parse( Console.ReadLine() );

        for ( int i = 0; i < n; ++i ) {
            string[] strings = Console.ReadLine().Split();

            switch ( strings[ 0 ] ) {
                case "S": { spades.Remove( strings[ 1 ] ); break; }
                case "H": { hearts.Remove( strings[ 1 ] ); break; }
                case "C": { clubs.Remove( strings[ 1 ] ); break; }
                case "D": { diamonds.Remove( strings[ 1 ] ); break; }

                default: { break; }
            }
        }

        Print( "S ", ref spades );
        Print( "H ", ref hearts );
        Print( "C ", ref clubs );
        Print( "D ", ref diamonds );
    }

    public static void Print( string prefix, ref List<string> list )
    {
        for ( int i = 0; i < list.Count; ++i ) {
            Console.WriteLine( prefix + list[ i ] );
        }
    }
}

Measured memory_bytes: 9244
n = input()

for i in range(2**3):
    calcu=['-']*3
    for j in range(3):
        if (i>>j)&1:
            calcu[3-1-j]='+'
    formula=''
    for tmp_1,tmp_2 in zip(n,calcu+['']):
        formula+=(tmp_1+tmp_2)
    if eval(formula)==7:
        print(formula+'=7')
        break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,k; cin >> n >> k;
    vector<Pll> ab(n);
    vector<ll> num(n,0);
    rep(i,n){
        ll a,b; cin >> a >> b;
        ab[i] = Pll(a,b);
    }
    sort(all(ab));
    num[0] = ab[0].second;
    rep(i,n-1)num[i+1] = num[i] + ab[i+1].second;
    ll idx = lower_bound(all(num), k) - num.begin();
    cout << ab[idx].first << endl;
}

Measured memory_bytes: 2560
/*input
6
1 1
2 2
3 3
4 4
5 5
6 6
*/
/**
    Author: Kristopher Paul
    Date Created: 08-09-2020
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

//Uncomment for File I/O
//ifstream fin("input.in")

//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    int d1[n],d2[n];
    FOR(i,0,n){
        cin >> d1[i] >> d2[i];
    }
    FOR(i,0,n-2){
        bool c = true;
        FOR(j,i,i+3){
            if(d1[j] != d2[j]){
                c = false;
            }
        }
        if(c == true){
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
char a[101000];
long long k,m;
int main()
{
    cin>>a;
    int n=strlen(a);
    for(int i=0;i<n;i++)
    {
        if(a[i]=='e')
        {
            if(a[i+1]=='r'&&a[i+2]=='a'&&a[i+3]=='s'&&a[i+4]=='e')
            {
                if(a[i+5]=='r')i+=5;
                else i+=4;
            }
        }
        else
			if(a[i]=='d')
	        {
	            if(a[i+1]=='r'&&a[i+2]=='e'&&a[i+3]=='a'&&a[i+4]=='m')
	            {
	                if(a[i+5]=='e'&&a[i+6]=='r'&&a[i+7]=='a'&&a[i+8]=='s'&&a[i+9]=='e')i+=4;
	                else
	                {
	                    if(a[i+5]=='e'&&a[i+6]=='r')i+=6;
	                    else i+=4;
	                }
	            }
	        }
        else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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

int main(void) {
    int R;
    cin >> R;
    if(R < 1200) {
        cout << "ABC\n";
    } else if(R<2800) {
        cout << "ARC\n";
    } else {
        cout << "AGC\n";
    }
    return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s1 = s_input()
    s2 = s_input()
    s3 = s_input()

    print(s1[0] + s2[1] + s3[2])

if __name__ == '__main__':
    main()


Measured memory_bytes: 77164
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

int n,mem;
int a[100001];
int mx;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int main(){
	cin >> n;
	lp(100001)
		a[i] = 0;
	lp(n) {
		cin >> mem;
		a[mem]++;
	}
	mx = intmin;
	lp(100001 - 2)
		mx = max(mx, a[i] + a[i + 1] + a[i + 2]);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#define MAX_K 201
using lli = long long int;
using namespace std;

int dp[MAX_K][MAX_K];

int gcd(int x,int y){
  if(x < y){
    int temp;
    temp = x;
    x = y;
    y = temp;
  }
  if(x % y == 0){
    dp[x][y] = y;
    return y;
  }

  if(dp[x][y]!= -1){
    return dp[x][y];
  }else{
    dp[x][y] = gcd(y,x % y);
    return dp[x][y];
  }
}


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

  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      dp[i][j]=-1;
    }
  }
  
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      if(dp[i][j]==-1){
	dp[i][j]=gcd(i,j);
      }
    }
  }

  lli sum=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
	sum += dp[dp[i][j]][k];
      }
    }
  }
    
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3744
N,T = map(int,input().split())
c = []
t = []
for _ in range(N):
  x,y = map(int,input().split())
  c.append(x)
  t.append(y)
L = []  
for i in range(N):
  if T >= t[i]:
    L.append(c[i])
if len(L) == 0:
  print("TLE")
else:    
  print(min(L))  

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  for (int i=0 ; i<s.size() ; i++){
    s.at(i) += n;
    if (s.at(i) > 'Z')
      s.at(i) -= 26;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, l; cin >> n >> l;
    vector<string> s(n);

    rep(i,n) cin >> s[i];

    string ans = "";
    sort(all(s));

    rep(i,n) ans += s[i];

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B;
	cin >> A >> B;
	cout << A * B << endl;
}

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

int main()
{
	string s;
	cin >> s;
	bool f = true;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] == s[j]) f = false;
		}
	}
	if (f) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
    int h, w;
    int i, j;
        cin >> h >> w;
    while (h != 0 && w != 0) {
        for (j = 1; j <= w; j++)
            cout << "#";
        cout << "\n";

        for (i = 3; i <= h; i++) {
            cout << "#";
            for (j = 3; j <= w; j++)
                cout << ".";
            cout << "#\n";
        }
        
        for (j = 1; j <= w; j++)
            cout << "#";
        cout << "\n\n";
        cin >> h >> w;
    }
}


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

int main() {
  vector<int> num (3);
  cin >> num.at(0) >> num.at(1) >> num.at(2);
  sort (num.begin(),num.end());
  vector<int> judge = {5,5,7};
  if(num == judge) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256