akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define FOR(i,a,b) for(int i=(a), i##_len=(b);i< i##_len; ++i)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int H, W;
char s[5000][5000];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

signed main()
{
    cin >> H >> W;
    REP(i, H) REP(j, W) cin >> s[i][j];

    REP(i, H) REP(j, W)
    {
        char c = s[i][j];
        if (c == '.') continue;
        bool cond = false;
        for (int k = 0; k < 4; ++k)
        {
            int x = dx[k];
            int y = dy[k];
            if (i+x < 0 || i+x > H-1 || j+y < 0 || j+y > W-1) continue;
            char t = s[i+x][j+y];
            if (t == '#') cond = true;

        }
        if (!cond)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

struct StExpr
{
  StExpr() : m_nPerson(0), m_nAttr(0) { }

  int m_nPerson;
  int m_nAttr;
};

void fnInput(vector<vector<StExpr>>& rvvoExpr)
{
  int nPersonSiz;
  cin >> nPersonSiz;
  rvvoExpr.resize(nPersonSiz + 1);

  for (int i = 1; i < rvvoExpr.size(); i++)
  {
    int nAttrSiz;
    cin >> nAttrSiz;
    rvvoExpr[i].resize(nAttrSiz);

    for (int j = 0; j < rvvoExpr[i].size(); j++)
      cin >> rvvoExpr[i][j].m_nPerson >> rvvoExpr[i][j].m_nAttr;
  }
}
 
int fnHonestCheck(const vector<vector<StExpr>>& cnrvvoExpr, 
                  const vector<int>& cnrvnHonest, int nMan)
{
  if (cnrvnHonest[nMan])               // Honest
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson ] )
        return 0;

    return 1;
  }
  else                                 // UnKind
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson ] )
        return 1;

    return 0;
  }
}
  
int fnMaxHonestGet(const vector<vector<StExpr>>& cnrvvoExpr)
{
  vector<int> vnHonest(cnrvvoExpr.size());
  int nMaxHonestCnt = 0;
  
  for (int n = 1; n < ( 1 << (cnrvvoExpr.size() - 1) ); n++)
  {
    int nHonestCnt = 0;

    for (int i = 0; i < cnrvvoExpr.size() - 1; i++)
      if (n & (1 << i))
      {
        vnHonest[i + 1] = 1;           // Honest
        nHonestCnt++;
      }
      else
        vnHonest[i + 1] = 0;           // UnKind

    bool bReslt = true;
    for (int nMan = 1; nMan < vnHonest.size(); nMan++)
      if (!fnHonestCheck(cnrvvoExpr, vnHonest, nMan))
      {
        bReslt = false;
        break;
      }

    if (bReslt) nMaxHonestCnt = max(nMaxHonestCnt, nHonestCnt);
  }
  return nMaxHonestCnt;
}

int main()
{
  vector<vector<StExpr>> vvoExpr;

  fnInput(vvoExpr);
  cout << fnMaxHonestGet(vvoExpr) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

void display(int data[], int n);
void bubbleSort(int data[], int n);
void selectionSort(int data[], int n);
void insertionSort(int data[], int n);

int main(){
	
	//??????
	int data[N];
	
	//??¶?????¨?????°
	int i, n;
	
	//????´???°?????\???
	scanf("%d", &n);
	
	
	//??????????????\???
	for(i=0; i<n; i++){
		
		scanf("%d", &data[i]);
		
	}
	
	//bubbleSort(data, n);
	
	selectionSort(data, n);
	
	return 0;
	
}



//?????????????´???????????????????
void display(int data[], int n){
	
	int i;
	
	for(i=0; i<n; i++){
		if(i>0){
			printf(" ");
		}
		printf("%d", data[i]);
	}
	
	printf("\n");
	
	return;
}



//??????????????????
void bubbleSort(int data[], int n){
	
	int i, j, temp;
	int count = 0;
	
	for(i=0; i<n; i++){
		
		for(j=n-1; j>i; j--){
			
			if(data[j] < data[j-1]){
				
				temp = data[j];
				data[j] = data[j-1];
				data[j-1] = temp;
				
				//?????°????¨????
				count++;
				
			}
			
		}
		
		//???????????¶????????????
		//display(data, n);
		
	}
	
	
	//??????
	display(data, n);
	
	//???????????°?????????
	printf("%d\n", count);
	
	return;
}



//???????????????
void selectionSort(int data[], int n){
	
	int i, k, temp;
	int min = 0;
	int count = 0;
	
	for(i=0; i<n; i++){
		
		min = i;
		
		for(k=i+1; k<n; k++){
			
			if(data[min] > data[k]){
				
				min = k;
				
			}
			
		}
		
		
		//min > i  ???  ??????????????????
		if(min > i){
			
			temp = data[min];
			data[min] = data[i];
			data[i] = temp;
			
			count++;
		}
		
	}
	
	display(data, n);
	
	//???????????°?????????
	printf("%d\n", count);
	
	return;
}



//?????\?????????
void insertionSort(int data[], int n){
	
	int i, j, temp;
	
	for(i=1; i<n; i++){
		
		j = i;
		temp = data[j];
		
		while(j>0 && temp < data[j-1]){
			
			data[j] = data[j-1];
			j--;
			
		}
		data[j] = temp;
		
		//???????????¶????????????
		//display(data, n);
	}
	
	return;
}

Measured memory_bytes: 604
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    print(n*n*3)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    ll n;
    cin>>n;
    vector<ll> v(n);
    ll ans=0;
    for(int i=0;i<n;++i)
        cin>>v[i];
    sort(all(v),greater<ll>());
    ans+=v[0];
    for(int i=1;i<n;++i)
        v.pb(v[i]);
    sort(all(v),greater<ll>());
    for(int i=1;i<=n-2;++i)
        ans+=v[i];
    cout<<ans;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 6332
#include<iostream>
using namespace std;
int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	  if(x==y && y==z)
	    cout<<"No";
    else if(x==y || y==z || x==z)
	 {
	 	cout<<"Yes";
	 	
	 }

     else
         cout<<"No";
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int s;
	int ans;
	cin >> s;
	int a[1000000];
	a[0] = s;
	for (int i = 0; ; i++) {
		if (a[i] == 4||a[i]==2||a[i]==1) {
			ans = i + 4;
			break;
		}
		if (a[i] % 2 == 0) {
			a[i + 1] = a[i] / 2;
		}
		else a[i + 1] = (3 * a[i]) + 1;
		
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    vector <ll> v;
    ll n, q, b, e, t;
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++){
        scanf("%lld", &t);
        v.push_back(t);
    }
    scanf("%lld", &q);
    for(ll i = 0; i < q; i++){
        scanf("%lld %lld", &b, &e);
        reverse(v.begin()+b, v.begin()+e);
    }
    for (auto i = v.begin(); i != v.end(); i++){
        if(i != v.begin()){
            printf(" ");
        }
        printf("%lld", *i);
    }
    printf("\n");
}




Measured memory_bytes: 3244
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

ans = sum(A)
if ans % 10 == 0:
    A.sort()
    for a in A:
        if (ans - a) % 10 != 0:
            ans -= a
            break
if ans % 10 == 0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int a[110],c[20];
int main(){
	int i,n,k = 0,x = 0;
  	cin >> n;
  	for(i=0;i<n;i++){
		cin >> a[i];
  	}
  for(i=0;i<n;i++){
	c[a[i]/400]++;
    if(a[i]>=3200) x++;
  }
  for(i=0;i<8;i++){
	if(c[i]) k++;
  }
  if(k==0) cout << 1 << " " ;
  else cout << k << " ";
  cout << k + x << endl;
}
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

void dfs(int64_t n, string& s, int64_t i, char next) {
    if (i == n) {
        cout << s << endl;
        return;
    }

    for (char c = 'a'; c <= next; ++c) {
        s[i] = c;
        dfs(n, s, i + 1, max((char)(c + 1), next));
    }
}

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

    string s;
    s.resize(n);
    dfs(n, s, 0, 'a');
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main() {
	long d,s;
	while(cin >> d){
		long D = d*d*d;
		s = 0;
		for(int i=1;i*d<600;i++){
			s += D*i*i;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;

int main(){
    int N;
    cin >> N;
    int V[N];
    int C[N];
    for(int i=0;i<N;i++) cin >> V[i];
    for(int i=0;i<N;i++) cin >> C[i];
    int a=0;
    for(int i=0;i<N;i++){
        if(V[i]>C[i]) a+= V[i]-C[i];
    }
    cout << a << endl;
}

Measured memory_bytes: 256
import math

N = int(input())

def get_sieve_of_eratosthenes(n):
  if not isinstance(n, int):
    raise TypeError('n is int type.')
  if n < 2:
    raise ValueError('n is more than 2')
  prime = []
  limit = math.sqrt(n)
  data = [i + 1 for i in range(1, n)]
  while True:
    p = data[0]
    if limit <= p:
      return prime + data
    prime.append(p)
    data = [e for e in data if e % p != 0]
 
P = get_sieve_of_eratosthenes(55555)

answer = []
for p in P:
  if p % 5 == 1:
    answer.append(p)
    if len(answer) == N:
      print(*answer)
      exit()


Measured memory_bytes: 42604
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	
	if((a % 3) == 0 || (b % 3) == 0 || ((a + b) % 3) == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_e

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w, i1, i2;
    ll t, ans = 0;
    cin >> n >> w;
    // dp は重さに対する価値を保存する
    // vector<int> dp(100001, INF);
    map<int, ll> dp, cp;
    dp[0] = 0;
    cp[0] = 0;
    REP(i, n) {
        cin >> i1 >> i2;
        for (const auto &x : dp) {
            ll weight = x.first + i1;
            if (weight <= w) {
                if (dp.count(weight) == 0) {
                    t = x.second + i2;
                } else {
                    t = max(dp[weight], x.second + i2);
                }
                cp[weight] = t;
                ans = max(ans, t);
            }
        }
        dp = cp;
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    sort(a.begin(),a.end());
    for (int i = 0;i < q;++i) {
        int l,r;
        cin >> l >> r;
        cout << upper_bound(a.begin(),a.end(),r)-lower_bound(a.begin(),a.end(),l) << "\n";
    }
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }


int main(int argc, char const *argv[]) {
  int n,k;
  cin >> n >> k;
  if(k==1) cout << "0" << endl;
  else cout << n-k << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val (k2, k4) = listOf(K * 2, K * 4)
    val B = Array(k2 + 1) { IntArray(k2 + 1) }
    repeat(N) {
        val xyc = listOfString()
        val c = xyc[0].toInt() % k2
        val r = xyc[1].toInt() % k2
        if (xyc[2] == "B") B[r][c] += 1 else B[r][(c + K) % k2] += 1
    }
    val S = Array(k4 + 1) { IntArray(k4 + 1) }
    for (r in 0 until k4) for (c in 0 until k4) S[r][c + 1] = S[r][c] + B[r % k2][c % k2]
    for (r in 0 until k4) for (c in 0 .. k4) S[r + 1][c] += S[r][c]
    var ans = 0
    fun num(r: Int, c: Int) = S[r + K][c + K] - S[r][c + K] - S[r + K][c] + S[r][c]
    for (r in 0 .. k2) for (c in 0 .. k2) {
        val b = num(r, c) + num(r + K, c + K)
        ans = Math.max(ans, b)
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }



Measured memory_bytes: 136688
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  V<string> s(h); for (auto&& e : s) cin >> e;
  VV<> l(h, V<>(w)), r(h, V<>(w));
  for (int i = 0; i < h; ++i) {
    int t = 0;
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '.') ++t;
      else t = 0;
      l[i][j] = t;
    }
    t = 0;
    for (int j = w - 1; j >= 0; --j) {
      if (s[i][j] == '.') ++t;
      else t = 0;
      r[i][j] = t;
    }
  }
  VV<> u(h, V<>(w)), d(h, V<>(w));
  for (int j = 0; j < w; ++j) {
    int t = 0;
    for (int i = 0; i < h; ++i) {
      if (s[i][j] == '.') ++t;
      else t = 0;
      u[i][j] = t;
    }
    t = 0;
    for (int i = h - 1; i >= 0; --i) {
      if (s[i][j] == '.') ++t;
      else t = 0;
      d[i][j] = t;
    }
  }
  int res = 0;
  for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) if (s[i][j] == '.') {
    res = max(res, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
  }
  cout << res << '\n';
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int result = 1;
  for (int i = 0; i < N; ++i) {
    if (result < K) {
      result += result;
    } else {
      result += K;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,s.size()){
        cout << char(65 + (s[i] - 'A' + n)%26);
    }
    cout << endl;
}

Measured memory_bytes: 3648
n = int(input())
mod = 10**9 + 7
c = [int(input()) for i in range(n)]

dp = [0 for i in range(n)]
dp[0] = 1
memo = {c[0]:0}
for i in range(1,n):
    if c[i] in memo:
        if memo[c[i]] != i-1:
            dp[i] =(dp[i-1] + dp[memo[c[i]]])%mod
            memo[c[i]] = i
        else:
            dp[i] = dp[i-1]
            memo[c[i]] = i
    else:
        dp[i] = dp[i-1]
        memo[c[i]] = i

print(dp[n-1])

Measured memory_bytes: 85412
#幅優先探索
#https://abc007.contest.atcoder.jp/submissions/2107192

R,C = map(int, input().split())
#sy,sx = map(int, input().split())
#gy,gx = map(int, input().split())

count=0

sy,sx = 2,2
gy,gx = R+1, C+1

c_org = [ [ -1 if c_org == "#" else 9999 for c_org in input()] for r in range(R)]

for i in range(R):
    c_org[i].append( -1)
    c_org[i].insert(0,-1)

    count=count+c_org[i].count(9999)

c_plus=[-1 for i in range(C+2)]

c=[]
c.append(c_plus)
for i in range(R):
    c.append(c_org[i])
c.append(c_plus)


#print(c)
 
c[sy - 1][sx - 1] = 0
 
neighbors = [(1, 0), (-1, 0), (0, 1), (0, -1)]
check_list = [(sy - 1, sx - 1)]
index = 0
 
while index < len(check_list):
    check_rc = check_list[index]
    for neighbor in [ (check_rc[0] + n[0], check_rc[1] + n[1]) for n in neighbors]:
        if c[neighbor[0]][neighbor[1]] >= 0 and  c[neighbor[0]][neighbor[1]] > c[check_rc[0]][check_rc[1]] + 1:
            c[neighbor[0]][neighbor[1]] = c[check_rc[0]][check_rc[1]] + 1
            check_list.append(neighbor)
    index += 1


#---------------------------------------------------
#print(c[gy - 1][gx - 1])
#print(count)
if c[gy - 1][gx - 1]!=9999:
    print(count-c[gy - 1][gx - 1]-1)
else:
    print(-1)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, m, k,cnt=0;
//=======================

void solve() {
    string s,t;
    cin >> s >> t;
    int mx= 1001;
    for(int i=0; i<=s.length() - t.length(); i++)
    {
      fo(j,t.length())
      {
        if(s[i+j] != t[j]) cnt++;
      }
      mx = min(mx, cnt);
      cnt=0;
    }
    cout << mx <<'\n';
}

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

    int t = 1;
    while(t--) {
      solve();
    }

    return 0;
}

Measured memory_bytes: 50528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,L;cin >> N >> L; 
  int sum = 0;
  int min = MAX_I;
  rep(i,N){
    sum += L+i;
    if(abs(L+i) < abs(min)) min = L+i;
  }
  cout << sum - min << endl;
  return 0;
} 


Measured memory_bytes: 256
import sys
import copy
R, C, K = map(int, input().split())
item = [[0] * (C + 1) for _ in range(R + 1)]  # dp配列と合わせるために, 0行目, 0列目を追加している.
for s in sys.stdin.readlines():
    r, c, v = map(int, s.split())
    r -= 1
    c -= 1
    item[r][c] = v
    
dp0 = [[0] * (C+1) for r in range(R+1)]
dp1 = [[0] * (C+1) for r in range(R+1)]
dp2 = [[0] * (C+1) for r in range(R+1)]
dp3 = [[0] * (C+1) for r in range(R+1)]

for r in range(R):
   for c in range(C):
      dp3[r][c] = max(dp3[r][c], dp2[r][c] + item[r][c])
      dp2[r][c] = max(dp2[r][c], dp1[r][c] + item[r][c])
      dp1[r][c] = max(dp1[r][c], dp0[r][c] + item[r][c])
      dp1[r][c+1] = max(dp1[r][c], dp1[r][c+1])
      dp2[r][c+1] = max(dp2[r][c], dp2[r][c+1])
      dp3[r][c+1] = max(dp3[r][c], dp3[r][c+1])
      dp0[r+1][c] = max(dp0[r+1][c], dp1[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp2[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp3[r][c])
ans = max(dp0[R-1][C-1], dp1[R-1][C-1])
ans = max(ans, dp3[R-1][C-1])
ans = max(ans, dp2[R-1][C-1])
print(ans)



Measured memory_bytes: 432584
# coding: utf-8
import math


def solve(*args: str) -> str:
    a, b, x = map(int, args[0].split())
    ret = 0.0
    if x < a*a*b/2:
        d = (2*x)/(a*b)
        ret = math.degrees(math.atan2(b, d))
    else:
        d = ((2*x)/(a*a)) - b
        ret = math.degrees(math.atan2(b-d, a))

    return str(ret)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(1)]))


Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  while(cin >> a >> b >> c && a!=-1||b!=-1||c!=-1){
    if(a==-1||b==-1)cout<<"F"<<endl;
    else if(a+b>=80)cout<<"A"<<endl;
    else if(a+b>=65)cout<<"B"<<endl;
    else if((a+b>=50)||(a+b>=30&&c>=50))cout<<"C"<<endl;
    else if(a+b>=30)cout<<"D"<<endl;
    else cout << "F" << endl;
  }
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, m;
    cin >> n >> m;

    int ans = 0;
    ans += min(n, m / 2);
    int tp = m;
    m -= min(2 * n, m - m % 2);
    n -= min(n, tp / 2);
    if (n == 0) {
        ans += m / 4;
    }
    cout << ans << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)

cb_dict = {}
for _ in range(m):
    b, c = map(int, input().split())
    new = {c:b}
    if c in cb_dict.keys():
        cb_dict[c] += b
    else:
        cb_dict.update(new)

cb_dict = sorted(cb_dict.items(), key=lambda x:x[0], reverse=True)

now_c = 0
now_b = 0
for i in range(n):
    if A[i] >= cb_dict[now_c][0]:
        break
    else:
        A[i] = cb_dict[now_c][0]
        now_b += 1
        if now_b == cb_dict[now_c][1]:
            now_c += 1
            now_b = 0
        if now_c > len(cb_dict)-1:
            break

ans = sum(A)
print(ans)

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

int N;
int A[200010];

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

    int sum = 0, sum_xor = 0, l = 0;
    long long ans = 0;
    for(int i = 0; i < N; i++)
    {
        sum += A[i];
        sum_xor ^= A[i];
        while(sum != sum_xor)
        {
            sum -= A[l];
            sum_xor ^= A[l];
            l++;
        }

        ans += i - l + 1;
    }

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


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>

using namespace std;

int main(){
	int h,w,x;
	
	cin >> h >> w >> x;
	
	if(h>w) cout << (x+(h-1))/h << endl;
	else cout << (x+(w-1))/w << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
double min(double a, double b)
{
    if (a < b)
        return a;
    else
        return b;
}
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    double a[1003], b[1003];
    int i;
    for (i = 0; i < n; i++)
        scanf("%lf", &a[i]);
    for (i = 0; i < m; i++)
        scanf("%lf", &b[i]);
    double x;
    for(i=0;i<n-1;i++)
        if (a[i] <= a[i + 1])
        {
            if (a[i] == a[i + 1])
            {
                printf("0\n");
                return 0;
            }
            x = a[i];
            a[i] = a[i + 1];
            a[i + 1] = x;
            if (i > 0)
                i -= 2;
        }
    for(i=0;i<m-1;i++)
        if (b[i] <= b[i + 1])
        {
            if (b[i] == b[i + 1])
            {
                printf("0\n");
                return 0;
            }
            x = b[i];
            b[i] = b[i + 1];
            b[i + 1] = x;
            if (i > 0)
                i -= 2;
        }
    double p = 1000000007;
    double ans = 1;
    int k = 0;
    int y;
    int j;
    int q;
    for (i = n * m; i >= min(a[n - 1], b[m - 1]); i--)
    {
        x = y = q = 0;
        j = 0;
        while (a[j] > i)
        {
            j++;
            x++;
        }
        if (a[j] == i)
        {
            x = 1;
            q++;
        }
        j = 0;
        while (b[j] > i)
        {
            y++;
            j++;
        }
        if (b[j] == i)
        {
            y = 1;
            q++;
        }
        if (q==0)
            ans *= x * y - k;
        else
            ans *= x * y;
        ans = round(fmod(ans, p));
        k++;
    }
    for (j = 0; j < i; j++)
    {
        ans *= j + 1;
        ans = round(fmod(ans, p));
    }
    printf("%.0lf\n", round(ans));
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
#define MOD 1000000007

int n, d;

int main() {
	cin >> n >> d;
	if (n % (d * 2 + 1) == 0)cout << n / (d * 2 + 1) << endl;
	else cout << n / (d * 2 + 1) + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n, a;
  cin >> n >> a;
  int ans = n*n - a;
  cout << ans << endl;
}






Measured memory_bytes: 256
from itertools import combinations
from bisect import bisect_right

def main():
    N, *L = map(int, open(0).read().split())

    L.sort()

    print(sum(bisect_right(L, L[i] + L[j] - 1, j + 1) - (j + 1) for i, j in combinations(range(N), 2)))

if __name__ == '__main__':
    main()

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

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

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    // int n  bool いたずらされる
    map<int, bool> isTrick;
    rep(i, n) isTrick[i] = true;

    for(int i = 0; i < k; ++i) {
        int d;
        cin >> d;

        vec a(d);

        rep(j, d) {
            cin >> a[j];
            a[j]--;
        }

        for(auto q : a) {
            isTrick[q] = false;
        }
    }

    int ans = 0;

    rep(i, n) {
        if(isTrick[i]) ++ans;
    }

    cout << ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))

int A, B;

int main()
{
	cin >> A >> B;

	if (A > 12)
	{
		cout << B << endl;
		return 0;
	}
	else if (A >= 6)
	{
		cout << B / 2 << endl;
		return 0;
	}
	else
	{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <algorithm>
#include <cstring>
using namespace std;
#define int long long
#define N 100010
inline int read(){
    char ch=getchar(); int x=0;
    for (;ch>'9'||ch<'0';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
int g[N],S[N],a[N],b[N],n,bit[N<<1+10];
void add(int x){for (;x<=n<<1;x+=x&-x) bit[x]++;}
int query(int x){int res=0; for (;x;x-=x&-x) res+=bit[x];return res;}
bool check(int x){
    for (int i=1;i<=n;i++) if (a[i]>x) g[i]=-1; else g[i]=1;
    memset(bit,0,16*(n+5));
    add(n);
    int sum=0;
    for (int i=1;i<=n;i++){
        S[i]=S[i-1]+g[i];
        sum+=query(S[i]+n-1);
        add(S[i]+n);
    }
    return sum>=((n*(n-1)/2+n)/2)+1;
}
signed main(){
    n=read();
    for (int i=1;i<=n;i++) a[i]=read(),b[i]=a[i];
    sort(b+1,b+1+n);
    int L=1,R=n,ans=0;
    while (L<=R){
        int mid=L+R>>1;
        if (check(b[mid])) ans=b[mid],R=mid-1;
        else L=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}

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

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

    ll now = 100;
    int ans = 0;
    while (now < x){
        now *= 1.01;
        ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll mx = 0;
    ll cnt = 0;
    for(ll i=n-2; i>=0; i--){
        if(a[i]>=a[i+1]) cnt++;
        else cnt = 0;
        mx = max(mx,cnt);
    }
    cout << mx << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(s.length()>k){
         for(int i=0;i<k;i++) cout<<s[i];
         cout<<"...";
    }
    else cout<<s;
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
bool graph[8][8]={};
int n,m;
int cnt=0;
void dfs(int now,vector<int> visited){
    visited[now]=true;
    bool all_visited=true;
    rep(i,n){
        if(!visited[i]){
            all_visited = false;
        }
    }
    if(all_visited){
        cnt++;//すべて訪問済みの場合のみ、条件を満たしている
        return ;
    }
    rep(i,n){
        if(!visited[i] && graph[now][i]){
            //頂点nowとiが結ばれており、iが未訪問ならばさらに探索する
            //cout<<now<<"->"<<i<<endl;
            dfs(i,visited);
        }
    }
}
int main(){
    cin>>n>>m;
    vector<int> visited(n,false);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        graph[a][b]=graph[b][a]=true;
    }
    dfs(0,visited);
    cout<<cnt<<endl;
}

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

int main() {
    int k, n;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];

    int ans = 0;
    while(1){
        if(ans == 0){
            ans++;
            n -= k;
        }else{
            ans++;
            n -= (k-1);
        }

        if(n <= 0){
            cout << ans << endl;
            return 0;
        }
    }
}

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

int main(){
  string s;
  cin >> s;
  int i = s.size(), p=0;
  
  while( s.size() >= p+2 ){
    if( s.at(p) != s.at(p+1) ){
	    s.erase(p,2);
        p = max(--p,0);
    }else{
	    p++;
    }
  }    
  cout << i - s.size() << endl;
  return 0;
}

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

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

	int ans = 0;
	int count = 0;
	for(int i = 0; i < N - 1; i++){
		if(H[i + 1] <= H[i]){
			count++;
		}
		else{
			count = 0;
		}

		ans = max(ans, count);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[N + 1];
		int[] b = new int[N + 1];
		for (int i = 1; i <= N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		int[] c = new int[M + 1];
		int[] d = new int[M + 1];

		for (int i = 1; i <= M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		for (int i = 1; i <= N; i++) {
			long dis = Long.MAX_VALUE;
			int minPos = 0;
			for (int j = 1; j <= M; j++) {
				if (dis > Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])) {
					dis = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
					minPos = j;
				}
				;
			}
			System.out.println(minPos);
		}

	}
}


Measured memory_bytes: 35956
N, Q = map(int, input().split())
S = input()
cumsum = [0] * N

for i in range(1, N):
    if S[i - 1] == 'A' and S[i] == 'C':
        cumsum[i] = cumsum[i - 1] + 1
    else:
        cumsum[i] = cumsum[i - 1]

for i in range(Q):
    l, r = map(int, input().split())
    print(cumsum[r-1] - cumsum[l-1])


Measured memory_bytes: 11612
//重点样例

//cin>>eraserase
//cout<<NO

//cin>>dreamerase
//cout<<YES
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	long long n,i,t;
	string a;
	cin>>a;
	n=a.size();
	for(i=0;i<n;){
		if(a[i]=='d'){
			if(a[i+1]=='r'&&a[i+2]=='e'&&a[i+3]=='a'&&a[i+4]=='m'){
				i+=5;
				if(a[i]=='e'&&a[i+1]=='r'&&a[i+2]=='d'||a[i]=='e'&&a[i+1]=='r'&&a[i+2]=='e'||a[i]=='e'&&a[i+1]=='r'&&i+2==n)
				i+=2;
			}
			else{
				cout<<"NO"<<endl;
				return 0;
			}
		}
		else if(a[i]=='e'){
			if(a[i+1]=='r'&&a[i+2]=='a'&&a[i+3]=='s'&&a[i+4]=='e'){
				i+=5;
				if(a[i]=='r')
				i+=1;
			}
			else{
				cout<<"NO"<<endl;
				return 0;
			}
		}
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>

int n, t, a;
int h[1010];
double ht[1010];
double distT[1010];

int main()
{
	scanf("%d%d%d", &n, &t, &a);
	
	
	double minDist = -1;
	int minI = -1;
	
	for (int i = 0 ; i < n ; i++)
	{
		
		scanf("%d", &(h[i]));
		ht[i] = t - h[i] * 0.006;
		distT[i] = fabs(a - ht[i]);
		if ((minDist < 0) || (minDist > distT[i]))
		{
			minDist = distT[i];
			minI = i;
		}
	}
	
	printf("%d\n", minI + 1);
	
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
const double pi=3.1415926535;
const ll  mod=1000000007;

long long substract(long long a,long long b){//差の絶対値　3項演算
  long long num=(a-b);
  return (num > 0) ? num : -num;}
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n)cin>>v[i];
  int Min=INT_MAX;
  rep(j,100){
    int sum=0;
    rep(k,n){
      sum+=pow(substract(j,v[k]),2);
    }
    Min=min(Min,sum);
  }
  cout<<Min;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) {
    return i / 2;
}

int left(int i) {
    return 2 * i;
}

int right(int i) {
    return 2 * i + 1;
}

int main() {
    int H, i, A[MAX+1];
    
    cin >> H;
    for (i = 1; i <= H; i++) cin >> A[i];
    
    for (i = 1; i <= H; i++) {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if ( parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if ( left(i) <= H ) cout << "left key = " << A[left(i)] << ", ";
        if ( right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int R, C;
vector<vector<bool>> Grid;
vvll DP;

ll f(int r, int c){
    if(r >= R or c >= C) return 0;
    if(r == R-1 and c == C-1) return 1;
    if(DP[r][c] != -1) return DP[r][c];
    if(Grid[r][c]) return DP[r][c] = 0;

    return DP[r][c] = (f(r+1, c)%MOD + f(r, c+1)%MOD)%MOD;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    cin >> R >> C;
    Grid.assign(R, vector<bool>(C, false));
    DP.assign(R, vll(C, -1));
    for(int i = 0; i < R; ++i){
        for(int j = 0; j < C; ++j){
            char c; cin >> c;
            Grid[i][j] = (c == '#');
        }
    }
    cout << f(0, 0) << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 8448
#include <stdio.h>

int main(){
  int N,M1=0,M2=0;
  int A[200002];
  scanf("%d",&N);
  for(int i=1;i<=N;i++)
    scanf("%d",A+i);
  for(int i=1;i<=N;i++){
    if(A[i]>=M1){
      M2=M1;
      M1=A[i];
    }else if(A[i]>=M2){
      M2=A[i];
    }
  }
  for(int i=1;i<=N;i++){
    if(A[i]==M1) printf("%d\n",M2);
    else printf("%d\n",M1);
  }
  return 0;
}

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

int main() {
    int N,b;
    int data[3][3];
    bool ans[3][3] = {0};
    bool count  =0;
    /*ビンゴカードの値を入力*/
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> data[i][j];
        }
    }
    cin >> N;
    /*ビンゴカードに当たりがあるか*/
    for (int k = 0; k < N; k++){
        cin >> b;
        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 3; j++){
                if(b == data[i][j])ans[i][j] =1;
            }
        }
    }
    /*ビンゴしているか*/
        //横の列
        for (int i = 0; i < 3; i++){
            if(ans[i][0]){
                if(ans[i][1]){
                    if(ans[i][2]){
                        count = 1;
                    }
                }
            }
        }
        //縦の列
        for (int i = 0; i < 3; i++){
            if(ans[0][i]){
                if(ans[1][i]){
                    if(ans[2][i]){
                        count = 1;
                    }
                }
            }
        }
        //右斜め
        for (int i = 0; i < 3; i++){
            if(ans[0][0]){
                if(ans[1][1]){
                    if(ans[2][2]){
                        count = 1;
                    }
                }
            }
        }
        //左斜め
        for (int i = 0; i < 3; i++){
            if(ans[0][2]){
                if(ans[1][1]){
                    if(ans[2][0]){
                        count = 1;
                    }
                }
            }
        }
    if(count)cout << "Yes" << endl;
    else     cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+7;
ll xx[maxn],yy[maxn],zz[maxn];
int x,y,z,k;
bool ok(ll p)
{
	int cnt=0;
	for(int i=0;i<x;i++)
	for(int j=0;j<y;j++)
	{
		for(int m=0;m<z;m++)
		{
			if((xx[i]+yy[j]+zz[m])<p) break;
			cnt++;
			if(cnt >= k)
			{
				//cout<<p<<" "<<cnt<<" "<<k<<endl; 
				return true;
			}
		}
	}
	return false;
}
int main()
{
	cin>>x>>y>>z>>k;
	for(int i=0;i<x;i++) scanf("%lld",&xx[i]);
	for(int i=0;i<y;i++) scanf("%lld",&yy[i]);
	for(int i=0;i<z;i++) scanf("%lld",&zz[i]);
	sort(xx, xx + x, greater<long long>());
	sort(yy, yy + y, greater<long long>());
	sort(zz, zz + z, greater<long long>());
	ll r=30000000000ll,l=0ll;//cout<<1<<endl;
	while(l<r-1)
	{
		ll mid=(l+r)/2ll;//cout<<1<<endl;
		if(ok(mid)) l=mid;
		else r=mid;
		//cout<<l<<" "<<r<<endl;
	}
	//cout<<2<<endl;
	vector<ll> v;
	for(int i=0;i<x;i++)
	for(int j=0;j<y;j++)
	{
		for(int m=0;m<z;m++)
		{
			if((xx[i]+yy[j]+zz[m]) < l) break;
			else v.push_back(xx[i]+yy[j]+zz[m]);
			//cout<<(xx[i]+yy[j]+zz[m])<<" "<<l<<endl;
		}
	}
	sort(v.begin(),v.end(),greater<ll>());
	for(int i=0;i<k;i++) cout<<v[i]<<endl;
}

Measured memory_bytes: 133212
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

def prime_decomposition(n):
    D = defaultdict(int)
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            D[i] += 1
            n //= i
        if n == 1:
            break
    if n != 1:
        D[n] += 1
    return D

n, p = LI()
D = prime_decomposition(p)
ans = 1
for k, v in D.items():
    ans *= (k ** (v // n))

print(ans)




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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    long A, B, C; cin >> A >> B >> C;

    times(100000, i) {
        if(A % 2 || B % 2 || C % 2) {
            cout << i ln;
            return 0;
        }
        long k = A + B + C;
        A = (k - A) / 2;
        B = (k - B) / 2;
        C = (k - C) / 2;
    }

    cout << -1 ln;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        String ss = s+s;
        if (ss.contains(t)) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716