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

int main(int argc, char* argv[]) {
  using std::cin;
  using std::cout;
  using std::string;

  string str;
  cin >> str;
  const string result = (atoi(str.substr(5, 2).c_str()) <= 4) ? "Heisei" : "TBD";
  cout << result;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
from copy import deepcopy
import queue
from collections import deque





def main():
    num = int(input())

    data = [[0 for i in range(10)] for j in range(10)]
    for i in range(1, num + 1):
        now_str = str(i)
        data[int(now_str[0])][int(now_str[-1])] += 1

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += data[i][j] * data[j][i]

    # print(data)
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 75712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const int inf=1e9;
int main(){
	int a; cin>>a;
	cout<<a + a * a + a * a * a<<endl;
}

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

class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		while (true) {
			
			String s = br.readLine();
			if (s == null) break;
			StringTokenizer st = new StringTokenizer(s,",");
			int number = Integer.parseInt(st.nextToken());
			double weight = Double.parseDouble(st.nextToken());
			double height = Double.parseDouble(st.nextToken());
			
			if (weight / (height * height) >= 25) {
				ans.add(number);
			}
			
		}
		
		if (ans.size() == 0) {
			
			System.out.println("該当なし");
			
		} else {
			
			for (int a : ans)
				System.out.println(a);
			
		}
		
	}
	
}

Measured memory_bytes: 9344
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false
#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
string S , T ;
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> S >> T ;

  REP(i,S.length()){
char tmp ;
  tmp =   S[S.length() - 1 ] ;
  for(int j = S.length()-1 ; j > 0 ;j--){
    S[j] = S[j-1];   

  }
  S[0] = tmp ;
  if (DEBUG){
    std::printf("******debug********\n");
    cout << S << endl;
    std::printf("******debug********\n");
  }


  if(S.compare(T)==0  ){
    cout << "Yes" << endl;
    return 0 ;
  }
  }
  cout << "No" << endl;
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int x;
    cin >> x;
    int i=0;
    while(x>0){
        x-=++i;
    }
    cout << i << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

#define int long long

using namespace std;

void Main()
{
	// 0, 1, 2
	// 3, 4, 5
	// 6, 7, 8
	vector<int> a(9, 0);
	for (int i = 0; i < 9; i++) {
		cin >> a[i];
	}

	int n = 0;
	cin >> n;

	vector <int> b(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

	for (auto& i : a) {
		auto itr = find(b.begin(), b.end(), i);
		if (itr == b.end()) {
			i = 0;
		}
	}

	for (int i = 0; i <= 7; i += 3) {
		if (a[i + 0] && a[i + 1] && a[i + 2]) {
			cout << "Yes" << endl;
			return;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (a[i + 0] && a[i + 3] && a[i + 6]) {
			cout << "Yes" << endl;
			return;
		}
	}
	if (a[0] && a[4] && a[8]) {
		cout << "Yes" << endl;
		return;
	}
	if (a[2] && a[4] && a[6]) {
		cout << "Yes" << endl;
		return;
	}

	cout << "No" << endl;
}

int32_t main()
{
	Main();
	return 0;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int A, B, C; cin >> A >> B >> C;
    int ans = mod+mod;
    int X, Y; cin >> X >> Y;
    int mx_ab = max(X, Y)*2;
    for(int ab = 0; ab <= mx_ab; ab+=2){
        int lack_a = max(0, X - ab/2);
        int lack_b = max(0, Y - ab/2);
        ans = min(ans, ab*C + lack_a*A + lack_b*B);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL n, a, b;
    cin >> n >> a >> b;

    if( a > b ) cout << 0;
    else if( n == 1 ) {
        if( a != b ) cout << 0;
        else cout << 1;
    } else {
        cout << (b - a) * (n - 2) + 1;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using ll = long long;

int main() {
  const long double pi = 3.1415926535;
  long double R;
  std::cin >> R;
  std::cout << std::fixed << std::setprecision(10) <<(2 * R * pi) << std::endl;
  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int g;
  rep(i, n){
    int a;
    cin >> a;
    if(i == 0) g= a;
    else g = __gcd(g, a);
  }
  cout << g << endl;
  return 0;
}

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

int main () {
  int S;
  cin >> S;
   int a[1000000];
  for(int i = 0; i < 1000000; i++ ) {
    if (i > 0) {
      if (a[i-1] % 2 == 0) {
        a[i] = a[i-1] / 2;
        for(int j = 0; j < i; j++) {
          if (a[j] == a[i]){
            cout << i+1 << endl;
            return 0;
          }
        }
      } else {
        a[i] = 3 * a[i-1] +1;
        for(int j = 0; j < i; j++) {
          if (a[j] == a[i]){
            cout << i+1 << endl;
            return 0;
          }
        }
      }
    } else {
      a[i] = S;
    }
  }
}

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

using namespace std;

#define il inline
#define re register int
#define Rep(i, s, e) for (re i = s; i <= e; ++i)
#define Dep(i, s, e) for (re i - s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout);

il int read() {
	int x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}

int n;
map<int, bool> M;

int main() {
	n = read(); bool flag = true;
	Rep(i, 1, n) {
		int x = read();
		if (M[x]) flag = false;
		M[x] = true;
	}
	return printf("%s", flag ? "YES" : "NO") & 0;
}

Measured memory_bytes: 9600
#include<iostream>  
#include<string>
using namespace std;
#define INF 999999

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

  while(true){
    bool exist_odd=false;
  	for(int j=0;j<N;j++){
      if(a[j]%2==1){
        cout<<count<<endl;
        return 0;
      }
      exist_odd=true;
      a[j]=a[j]/2;
    }
    count++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 3e5 + 5;

int main()
{
    double r;
    cin>>r;
    cout<<setprecision(12)<<fixed<<2*acos(-1)*r<<'\n';
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int M[105][105];
int V[105];

int main()
{
	int n, m;
	cin >> n >> m;
	REP(i, n)
	{
		REP(j, m)
		{
			cin >> M[i][j];
		}
	}
	REP(i, m)
	{
		cin >> V[i];
	}
	REP(i, n)
	{
		int s = 0;
		REP(j, m)
		{
			s += M[i][j] * V[j];
		}
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define ll long int

ll ans = 0;

const int N = pow(10,5) + 20;
bool x[N] = {};

double fanc(ll t,ll x){
    return t - x * 0.006;
}

int main(){
    double n,t,a,ans,result,includes;

    cin >> n >> t >> a;
    
    double h;
    cin >> h;
    result = fanc(t,h);
    ans = 1;
    for(int i = 2; i <= n; ++i){
        cin >> h;
        if(abs(result - a) > abs(fanc(t,h) - a)){
            ans = i;
            result = fanc(t,h);
        } 
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    while (n--)
    {
        int a;
        cin >> a;
        mp[a]++;
        mp[a-1]++;
        mp[a+1]++;
    }
    int maxx = 0;
    for (auto x:mp)
        maxx = max(maxx, x.second);
    cout << maxx;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for(int i = 0; i < N; i++) {
        cin >> H.at(i);
    }
    sort(H.begin(), H.end(), greater<int>());
    ll ans = 0;
    for(int i = K; i < N; i++) {
        ans += H.at(i);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> h(n+1);
    for(long long i = 1;i < n+1;i ++){
        cin >> h.at(i);
    }
    vector<long long> s(n+1);

    s.at(0) = 10000000;

    for(long long i = 2;i < n+1;i ++){
        long long a = s.at(i-1) + abs(h.at(i) - h.at(i-1));
        long long b = s.at(i-2) + abs(h.at(i) - h.at(i-2));
        s.at(i) = min(a,b);
    }

    cout << s.at(n) << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;
int N,K;
int dfs(int o,int k,const vector<vector<int>>&Graph){
    int nowc=(o==-1?K-1:K-2);
    if(K<Graph[k].size())return 0;
    else{
        int pat=1;
        for(auto v:Graph[k]){
            if(v==o)continue;
            pat*=nowc;
            nowc--;
            pat%=MOD;
        }
        for(auto v:Graph[k]){
            if(v==o)continue;
            pat*=dfs(k,v,Graph);
            pat%=MOD;
        }
        return pat%MOD;
    }
}

signed main(){
    cin>>N>>K;
    vector<vector<int>>Graph(N);
    REP(i,N-1){
        int a,b;cin>>a>>b;--a;--b;
        Graph[a].pb(b);
        Graph[b].pb(a);
    }
    cout<<K*dfs(-1,0,Graph)%MOD<<endl;
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    set <int> s;
    bool t=1;
    for(int i=0;i<n;i++)
    {
        int x=nxt();
        if(s.count(x))
            t=0;
        s.insert(x);
    }
    if(t)
        cout<<"YES\n";
    else
        cout<<"NO\n";
  

    return 0;   
}


 
 


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

int main() {
	int a; scanf("%d",&a);
	int L=a/100;
	int R=a%100;
	if(1<=L&&L<=12) {
		if(1<=R&&R<=12) printf("AMBIGUOUS\n");
		else printf("MMYY\n");
	} else {
		if(1<=R&&R<=12) printf("YYMM\n");
		else printf("NA\n");
	}
	return 0;
}

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

int main()
{
  int x, y; cin >> x >> y;
  bool flg = false;

  rep(i, x+1) {
    rep(j, x+1) {
      if(i*4 + j*2 == y && i+j == x) flg=true;
    }
  }
  if (flg == false) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include"bits/stdc++.h"
#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 all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int n;
    cin >> n;
    ll sum = 0;
    REPS(i, n) {
        if (n % i == 0)sum--;
        sum += (n / i);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
ll N, L;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> L;
    vector<string> S(N);
    
    rep(i,N) {
        cin >> S[i];
    }

    sort(all(S));
    
    string ans = "";
    
    rep(i,N) {
        ans += S[i];
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 16;
const ll LINF = 1e18 + 5;
int n, a[N][N];
ll dp[1<<N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
	cin >> n;
	for(int i=0; i<n; i++) 
		for(int j=0; j<n; j++)
			cin >> a[i][j];
	for(int i=1; i<(1<<n); i++)
	{
		for(int j=0; j<n; j++)
			for(int k=j+1; k<n; k++)
				if((i>>j)&1 && (i>>k)&1) dp[i] += a[j][k];
		for(int j=i; j>0; j=(j-1)&i)
		{
			int k = i^j;
			dp[i] = max(dp[i], dp[j]+dp[k]);
		}
	}
	ll ans = dp[(1<<n)-1];
	cout << ans;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < (int)s.length() - 1; ++i) {
		ans += s[i] != s[i + 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int num_fac(int x)
{
    int count = 0;

    for (int i = 1; i <= x; i++) {
        if (x % i == 0) {
            ++count;
        }
    }

    return count;
}

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

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 2 == 1 && num_fac(i) == 8) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
int main()
{
    int t,i,j;
    cin>>t;
    int c=0,cn=0,cn1=0,cn2=0;
    while(t--){
        string s,ss;

        cin>>s;
        if(s=="AC")c++;
        else if(s=="TLE")cn++;
        else if(s=="WA")cn1++;
        else if(s=="RE")cn2++;
    }
        cout<<"AC x "<<c<<endl<<"WA x "<<cn1<<endl<<"TLE x "<<cn<<endl<<"RE x "<<cn2<<endl;
    return 0;
}


Measured memory_bytes: 3632
def is_palindrome(s: str) -> bool:
    return s[::-1] == s

s = input()
n = len(s)
print(
  "Yes"
  if (
    is_palindrome(s)
    and is_palindrome(s[: int((n - 1) / 2)])
    and is_palindrome(s[int((n + 3) / 2) - 1 :])
  )
  else "No"
)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    void solve() {
        string s;
        cin >> s;
        int n = s.size();
        auto is = [](string s) {
            int l = 0, r = s.size() - 1;
            while (l <= r) {
                if (s[l] != s[r]) {
                    return false;
                }
                ++l;
                r--;
            }
            return true;
        };
        if (is(s) && is(s.substr(0, n / 2)) && is(s.substr(n / 2 + 1, n / 2))) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string>
#define ll long long int
using namespace std;

const int m=1000000007;

int main()
{
    ll n,d;
    cin>>n>>d;
    vector<pair<int, int>>p;
    vector<double>v;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        v.push_back(sqrt(x*x+y*y));
    }
    int cnt=0;
    for(int i=0;i<v.size();i++)
    {
        if(v[i]<=d)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 5288
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, M, p[112345];
string S[112345];

int main() {

	cin >> N >> M;
	rep(i, M) cin >> p[i] >> S[i];
	vector<bool> IsAC(N, false);
	vector<int> WAC(N, 0);

	rep(i, M) {
		if (S[i] == "AC") IsAC[p[i] - 1] = true;
		else if (IsAC[p[i] - 1] == false) WAC[p[i] - 1]++;
	}

	int AC = 0, WA = 0;

	rep(i, N) if (IsAC[i]) {
		AC++;
		WA += WAC[i];
	}
	cout << AC << " " << WA << endl;

	return 0;
}


Measured memory_bytes: 6656
n = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for _ in range(n):
  judge = input()
  if judge == 'AC':
    AC += 1
  elif judge == 'WA':
    WA += 1
  elif judge == 'TLE':
    TLE += 1
  elif judge == 'RE':
    RE += 1

print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))

Measured memory_bytes: 9208
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
  long N, A, B;
  cin >> N >> A >> B;
  
  long a = 0;
  if (A == 0) {
    cout << 0 << endl;
    return 0;
  }
  a = (N / (A+B))*A + min(N % (A+B), A);
  cout << a << endl;
}

Measured memory_bytes: 256
input = gets.chomp

s1 = []
s2 = [[0,0]]

input.chars.each_with_index do |c, i|
  case c
  when "\\"
    s1.push(i)
  when "/"
    tmp = s1.pop

    if !tmp
      next
    end

    a=[]
    a.push(s2.pop) while tmp < s2[-1][0]
    s2.push([tmp, i-tmp + a.inject(0){|sum, x| sum += x[-1]}])
  end
end

puts s2.drop(1).inject(0){|sum, s| sum + s[1]}, ([s2.drop(1).length] + s2.drop(1).map{|s| s[-1]}).join(" ")


Measured memory_bytes: 8132
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
//#define int long long
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
    #ifdef OnlineJudge
    freopen("commandos.in","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
}
ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.
ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}
ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}
int * LIS_Lengths(vector<int> a) { int* lis = new int[a.size()];int b[a.size()];int maxLength = 1, lowerBound;lis[0] = 1, b[0] = a[0];for (size_t i = 1; i < a.size(); i++) {lowerBound = lower_bound(b, b + maxLength, a[i]) - b;lis[i] = lowerBound + 1;if (lowerBound == maxLength)    b[maxLength++] = a[i];else    b[lowerBound] = a[i];}return lis;}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int dr[] = {0,0,0,1,1,1,-1,-1,-1};
int dc[] ={-1,0,1,-1,0,1,-1,0,1};
/// <<------------------------------------------------------------------------------>>

/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    int a,b,c;
    cin >> a >> b >> c;
    if(c >= a && c <= b)
        cout<<"Yes";
    else cout<<"No";


}


Measured memory_bytes: 256
def main():
    q = int(input())
    p_s = primes()
    is_like_2017 = is_like_2017_function(p_s)

    counter = 0

    memo = [0] * (10**5+1)

    for i in range(0, 10**5+1):
        if is_like_2017(i):
            counter += 1
        memo[i] = counter

    for _ in range(q):
        l, r = map(int, input().split(' '))
        print(memo[r] - memo[l-1])


def is_like_2017_function(primes):
    def _f(num):
        if primes[num] and primes[(num+1)//2]:
            return True
        else:
            False
    return _f


def primes():
    MAX = 10**5+1
    result = [True] * MAX
    result[0] = False
    loop_max = int(MAX**0.5) + 1
    for i in range(loop_max):
        if result[i]:
            for j in range((i+1)*2 - 1, MAX, (i+1)):
                if (j+1) % (i+1) == 0:
                    result[j] = False
    return [False] + result


if __name__ == '__main__':
    main()


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string
#define fill1(a, c, x) fr(_I, 0, (c)) (a)[_I] = (x)
#define fill2(a, r, c, x) fr(_I, 0, (r)) fr(_J, 0, (c)) (a)[_I][_J] = (x)
#define boost ios_base::sync_with_stdio(false)
#define sz(x) ((int)(x).size())
#define deb(x) cout << #x" = " << x << '\n';
#define dist(x1, y1, x2, y2) sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main() {
//    freopen("input.in", "r", stdin);
	int n, l;
	scanf("%d %d", &n,&l);
	vector<string> res;
	res.reserve(1234);
	fr(i, 0, n) {
		string vie;
		cin >> vie;
		res.pb(vie);
	}
	sort(all(res));
	tr(it, res) cout << *it;
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int a[100000];

int main(void) {
    int i, n;
    scanf("%d",&n);
    REP (i,n) scanf("%d",&a[i]);
    sort(a,a+n);

    map<int,int> mp;
    REP (i,n) mp[a[i]]++;

    int ans = 0;
    REP (i,n) ans = max(ans,mp[a[i]-1] + mp[a[i]] + mp[a[i]+1]);

    printf("%d\n",ans);
    return 0;
}

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

Measured memory_bytes: 49496
#include<bits/stdc++.h>
using namespace std;
const int N=500010;
int n,a[N];
struct Node{
	int pos,l,r;
}b[N];
int tot,point[N],f[N];
int main(){
	char c;
	int x;
	scanf("%d\n",&n);
	for(int i=1;i<=n;i++){
		c=getchar();
		a[i]=c=='1';
	}
	int t=0;
	bool flag=0;
	for(int i=1;i<=n+1;i++){
		if(a[i]) t++;
		else{
			if(t){
				flag=1;
				if(tot&&!b[tot].r) b[tot].r=t;
				if(b[tot].r||!tot) point[b[tot].pos]=tot,tot++;
				b[tot].l=t,b[tot].pos=i;
				t=0;
			}else if(flag) tot--,flag=0;
		}
	}
	tot--;
	for(int i=1;i<=n;i++){
		f[i]=max(f[i],f[i-1]);
		if(point[i]){
			x=point[i];
			f[i+1]=max(f[i+1],max(f[i-b[x].l-1]+b[x].l,f[i-b[x].l]+b[x].l-1));
			f[i+b[x].r]=max(f[i+b[x].r],f[i-2]+b[x].r);
			f[i+b[x].r-1]=max(f[i+b[x].r-1],f[i-2]+b[x].r-1);
		}
	}
//	for(int i=1;i<=tot;i++) cout<<b[i].l<<" "<<b[i].pos<<" "<<b[i].r<<endl;
//	for(int i=1;i<=n;i++) cout<<f[i]<<" ";
//	cout<<endl;
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 9856
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;

int main()
{
	int n;
	cin >> n;
	double sum = 0;
	for (int i = 0; i < n; i++) {
		double x;
		string s;
		cin >> x >> s;

		if (s == "BTC") {
			x = x * 380000.0;
		}
		sum = sum + x;

	}
	
	cout << sum << endl;
	return 0;

}


Measured memory_bytes: 256
s = input()
K = int(input())

d = dict()
SET = set()
for i in range(len(s)):
    if not d.__contains__(s[i]):
        d[s[i]] = []
    d[s[i]].append(i)


alphabet = 'abcdefjhijklmnopqrstuvwxyz'

for c in alphabet:
    if not d.__contains__(c):
        continue
    l = d[c].copy()
    SET.add(c)
    if(len(SET) >= K):
        break
    tmp = []
    for idx in l:
        if idx+1>=len(s):
            continue
        tmp.append((idx,s[idx+1:len(s)]))
    tmp.sort(key = lambda x:x[1])
    for idx,nxt in tmp:
        for step in range(2,len(s)+1):
            if idx+step>len(s):
                break
            if s[idx:idx+step] not in SET:
                SET.add(s[idx:idx+step])
                if len(SET) >= K:
                    break
        if len(SET) >= K:
            break
    if len(SET) >= K:
         break

res = list(SET)
res.sort()
print(res[K-1])


Measured memory_bytes: 16116
import sys
from collections import deque
import math
input=sys.stdin.readline


n,m=map(int,input().split())
v=tuple(tuple(map(lambda x: int(x)-1,input().split())) for _ in range(m))
node=[[] for _ in range(n)]
d=deque()
ans=[-1]*n
ans[0]=0
d.append(0)
for pair in v:
    node[pair[0]].append(pair[1])
    node[pair[1]].append(pair[0])
while True:
    if not d:
        break
    a=d.popleft()
    l=node[a]
    for i in l:
        if ans[i]==-1:
            d.append(i)
            ans[i]=a+1
if -1 in ans:
    print("No")
    exit()
print("Yes")
for i in range(1,n):
  print(ans[i])


Measured memory_bytes: 124868
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int f(int n) {
  int sum = 0;
  while (n) {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

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

  int ans = 1<<30;
  for (int i = 1; i <= N/2; ++i) {
    ans = min(ans, f(i)+f(N-i));
  }

  cout << ans << endl;
}

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

int main() {
    int n; cin >> n;
    vector<tuple<string, int, int>> d(n);
    for(int i = 0; i < n; ++i) {
        string s; int p; cin >> s >> p;
        d[i] = make_tuple(s, -p, i);
    }
    sort(d.begin(), d.end());
    for(auto e : d) cout << get<2>(e) + 1 << endl;
}


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

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

    sort(NArray, NArray + N);
    
    cout << NArray[N-1] - NArray[0] << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#define MOD 998244353
long long int DP[3010][3010];
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	
	long long int C = 1;
	for(int j=c;j>=a;j--)
	{
		DP[d][j] = C;
		C*=d;
		C%=MOD;
	}
	
	for(int i=d-1;i>=b;i--)
	{
		C = 0;
		for(int j=c;j>=a;j--)
		{
			DP[i][j] = (C + j*DP[i+1][j])%MOD;
			
			//C *= i;
			C += DP[i+1][j];
			C *= i;
			C %= MOD;
			//printf("%d %d %lld!!\n",i,j,DP[i][j]);
		}
	}
	
	printf("%lld",DP[b][a]);
}

Measured memory_bytes: 72260
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

bool judge2d(int, int, int);

int main(){
    //cout << (-1 % 2 == 1 % 2) << endl;
    int n;
    cin >> n;

    int x[100010], y[100010], t[100010];
    int temp;

    t[0] = 0;
    x[0] = 0;
    y[0] = 0;

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

    bool success = false;
    for (int i = 0; i < n; i++){
      success = judge2d(x[i+1] - x[i], y[i+1] - y[i], t[i+1] - t[i]);
      if(!success) break;
    }
  if (success) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

bool judge2d(int x, int y, int n){
  int d = abs(x) + abs(y);
  if (d <= n && (d % 2 == n % 2)) return true;
  else return false;
}

Measured memory_bytes: 1408
#include <stdio.h>
#define INF 1000000
#define BLACK 1
#define WHITE 0
#define NIL -1
#define N 2000

int a[N][N], v[N],c[N], d[N];
int n, k;

void prim()
{
  int i, j, u, v, count=0, mincost,pi[N],color[N];
  for( i=0 ; i<n ; i++ ){
    d[i] = INF;
    pi[i]=NIL;
    color[i]=WHITE;
  }
  d[0] = 0;
  while(1){
    mincost = INF;
    for( i=0 ; i<n ; i++ ){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost = d[i];
	u=i;
      }
    }
    if(mincost==INF)
      break;

    color[u] = BLACK;
    for( v=0 ; v<n ; v++ ){
      if(color[v]!=BLACK && d[v]>(a[u][v]+d[u])){
	pi[v] = u;
	d[v] = a[u][v]+d[u];
      }
    }
  }
  for( i=0 ; i<n ; i++ )
    printf("%d %d\n",i,d[i]);
}

int main()
{
  int i, j, u;
  scanf("%d",&n);
  for( i=0 ; i<n ; i++ )
    for( j=0 ; j<n ; j++ )
      a[i][j]=INF;
  
  for( i=0 ; i<n ; i++ ){
    scanf("%d%d",&u,&k);
    for( j=0 ; j<k ; j++ ){
      scanf("%d%d",&v[j],&c[j]);
      a[u][v[j]]=c[j];
    }
  }
  prim();

  return 0;
}

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

int main() {
    long n, k;
    long a,b;
    long i, j;
    long long int sum=0;
    cin >> n >> k;
    for (i = k; i <= n; i++) {
        a = (i - 1) * i / 2;
        b = (2 * (n - i + 1) + (i - 1)) * i / 2;
        for (j = a; j <= b; j++) sum += 1;
    }
    sum = sum % 1000000007;
    cout << sum+1 << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

#define int long long

signed main(){
	int n;
	cin >> n;
	cout << n/500*1000 + (n%500)/5*5 << endl;
	return 0;
}

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

namespace ABC078A
{
    class Program
    {
        static void Main(string[] args)
        {
            string X, Y;
            var word = Console.ReadLine().Split(' ');
            X = word[0];
            Y = word[1];

            if (X[0] > Y[0])
                Console.WriteLine(">");
            else if (X[0] < Y[0])
                Console.WriteLine("<");
            else
                Console.WriteLine("=");
            Console.ReadKey();



        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

struct Node {
  Node(int lx, int ly, int rx, int ry) {
    this->lx = lx;
    this->ly = ly;
    this->rx = rx;
    this->ry = ry;
  }

  int val() {
    return lx * 8000000 + ly * 40000 + rx * 200 + ry;
  }

  int lx;
  int ly;
  int rx;
  int ry;
};

bool done[52][52][52][52];
int main() {
  vector<vector<char> > f(103);
  for (int i = 0; i < f.size(); i++) {
    f[i].resize(52);
  }

  int oki = 0;
  while (true) {
    int W, H;
    cin >> W >> H;

    if (W == 0) {
      break;
    }

    int cw = W + 1;
    int w = W * 2 + 3;
    int h = H + 2;
    for (int i = 0; i < w; i++) {
      f[i][0] = f[i][h - 1] = '#';
    }
    for (int i = 0; i < h; i++) {
      f[0][i] = f[cw][i] = f[w - 1][i] = '#';
    }

    char lx = 0, ly = 0;
    char rx = 0, ry = 0;
    for (char i = 1; i < h - 1; i++) {
      for (char j = 1; j < cw; j++) {
  cin >> f[j][i];
  if (f[j][i] == 'L') {
    lx = j;
    ly = i;
    f[j][i] = '.';
  }
      }
      for (char j = cw + 1; j < w - 1; j++) {
  cin >> f[j][i];
  if (f[j][i] == 'R') {
    rx = j;
    ry = i;
    f[j][i] = '.';
  }
      }
    }

    set<int> s;
    memset(done, 0, sizeof(done));
    queue<Node> q;
    q.push(Node(lx, ly, rx, ry));
    int cnt = 0;
    while (!q.empty()) {
      Node n = q.front();

      if (f[n.lx][n.ly] == '%' && f[n.rx][n.ry] == '%') {
  cout << "Yes" << endl;
  break;
      }
      q.pop();
      ++cnt;
      if (f[n.lx][n.ly] == '%' || f[n.rx][n.ry] == '%') {
        continue;
      }

  //     if (s.count(n.val()) != 0) {
  // continue;
  //     }
  //     s.insert(n.val());
      // cerr << "here" << endl;
      // cerr << n.lx << ", " << n.ly << " : " << n.rx << ", " << n.ry << endl;
      if (done[n.lx][n.ly][n.rx - cw][n.ry]) {
        continue;
      }
      done[n.lx][n.ly][n.rx - cw][n.ry] = true;

      q.push(Node(n.lx,
        f[n.lx][n.ly - 1] != '#' ? n.ly - 1 : n.ly,
        n.rx,
        f[n.rx][n.ry - 1] != '#' ? n.ry - 1 : n.ry)
      );
      q.push(Node(
        f[n.lx - 1][n.ly] != '#' ? n.lx - 1 : n.lx,
        n.ly,
        f[n.rx + 1][n.ry] != '#' ? n.rx + 1 : n.rx,
        n.ry)
      );
      q.push(Node(
        f[n.lx + 1][n.ly] != '#' ? n.lx + 1 : n.lx,
        n.ly,
        f[n.rx - 1][n.ry] != '#' ? n.rx - 1 : n.rx, 
        n.ry)
      );
      q.push(Node(
        n.lx,
        f[n.lx][n.ly + 1] != '#' ? n.ly + 1 : n.ly,
        n.rx,
        f[n.rx][n.ry + 1] != '#' ? n.ry + 1 : n.ry)
      );
    }
    oki = max(oki, cnt);
    if (q.empty()) {
      cout << "No" << endl;
    }
  }
  // cerr << oki << endl;

  return 0;
}

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

int main(){

    int N;
    cin >> N;
    int A[N+4];
    for(int i = 2;i<=N+1;i++) cin >> A[i];
    A[0] = 0;
    A[1] = 0;
    A[N+2] = 0;
    A[N+3] = 0;

    long int S = 0;
    for(int i = 1;i<=N+2;i++){
        S += abs(A[i] - A[i+1]);
    }
    //cout << "Sは" << S << endl;

    for(int i = 2;i<=N+1;i++){
        int cnt = 0;
        long int T = S;
        S += abs(A[i-1] - A[i+1]) -(abs(A[i-1] - A[i])+abs(A[i] - A[i+1]));
        cout << S << endl;
        S = T;
    }

    return 0;
}

Measured memory_bytes: 1664
S = gets.chomp
N = S.length
MOD = 10**9+7
dp = [1,0,0,0] # 3^cnt(X),A,AB,ABC
N.times do |i|
	prev = dp.dup
	c = S[i]
	if c == "A"
		dp[1] += prev[0]
	elsif c == "B"
		dp[2] += prev[1]
	elsif c == "C"
		dp[3] += prev[2]
	else
		dp[1] += prev[1]*2 + prev[0]
		dp[2] += prev[2]*2 + prev[1]
		dp[3] += prev[3]*2 + prev[2]
		dp[0] *= 3
	end
	dp[0] %= MOD
	dp[1] %= MOD
	dp[2] %= MOD
	dp[3] %= MOD
end

p dp[3]

Measured memory_bytes: 2044
import sys
input = sys.stdin.readline
s = list(input())[:-1]
k = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
n = 0
while n < len(s) and n < k:
    if s[n] != '1':
        print(s[n])
        break
    n += 1
else:
    print('1')

Measured memory_bytes: 3060
n,m=gets.split.map(&:to_i)
xs = gets.split.map(&:to_i).sort
distances = Array.new(m-1)

(0..xs.length-2).each_with_index do |_, i|
  distances[i] = xs[i+1]-xs[i]
end

p distances.sort[0..-n].inject(:+) || 0

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(value_type _n):n(_n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, t; cin>>h>>w>>t;
    ll Gh = __gcd(h, t);
    ll Gw = __gcd(w, t);
    ll H = h/Gh;
    ll W = w/Gw;
    ll GHW = __gcd(H, W);
    mint ans;
    ans = mint(2).pow(W)+mint(2).pow(H)+mint(2).pow(GHW)-3;
    ans = ans.pow(Gh*Gw);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
        string s,t;
        cin >> s >> t;
        for(int i=0 ; i<s.size() ; i++ ){
                for(int j=i+1 ; j<s.size() ; j++ ){
                        if((int)(s[i])>(int)(s[j])){
                                swap(s[i],s[j]);
                        }
                }
        }
        for(int i=0 ; i<t.size() ; i++ )
                for(int j=i+1 ; j<t.size() ; j++ )
                        if((int)(t[i])<(int)(t[j]))
                                swap(t[i],t[j]);
        int lim= s.size()>t.size()?t.size():s.size();
        for(int i=0 ; i<lim ; i++ ){
                if((int)(s[i])<(int)(t[i])){
                        cout <<"Yes"<<endl;
                        return 0;
                }
                else if((int)(s[i])==(int)(t[i]))
                        continue;
                else{
                        cout << "No"<<endl;
                        return 0;
                }
        }
        if(s.size()<t.size()){
                cout <<"Yes"<<endl;
                return 0;
        }
        cout << "No"<<endl;
        return 0;
}

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

#define int int_fast64_t

int next_power_of_two(int n) {
  int p = 1;
  while (p <= n)
    p *= 2;
  return p;
}

struct fenwick {
  int n;
  vector<int> d;
  fenwick(int n) : n(next_power_of_two(n)), d(this->n) {}

  int query(int i) {
    int s=0;
    for (++i; i; i -= i&-i)
      s += d[i];
    return s;
  }

  void incr(int i) {
    for (++i; i < n; i += i&-i)
      d[i] += 1;
  }
};

int solve(string const& s) {
  array<int, 'z'-'a'+1> count = {};
  for (char c : s) ++count[c-'a'];

  array<int, 'z'-'a'+1> lefties = {};
  char single = '\0';
  for (size_t i=0; i<count.size(); ++i) {
    lefties[i] = count[i]/2;
    if (count[i]%2) {
      if (single)
        return -1;
      single = 'a' + i;
    }
  }
  string t;
  for (char c : s) {
    if (lefties[c - 'a']) {
      --lefties[c - 'a'];
      t.push_back(c);
    }
  }
  {
    string t_cpy = t;
    if (single)
      t.push_back(single);
    t.insert(t.end(), t_cpy.rbegin(), t_cpy.rend());
  }

  array<vector<int>, 'z'-'a'+1> positions = {};
  array<int, 'z'-'a'+1> position_index = {};
  for (size_t i=0; i<s.size(); ++i)
    positions[s[i]-'a'].push_back(i);

  vector<int> perm;
  for (char c : t)
    perm.push_back(positions[c-'a'][position_index[c-'a']++]);

  int ops = 0;
  fenwick ft(perm.size());
  for (size_t i=0; i<perm.size(); ++i) {
    ops += i - ft.query(perm[i]);
    ft.incr(perm[i]);
  }
  return ops;
}

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

  string s; cin >> s;
  cout << solve(s) << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 e.cc -o e && for f in *.in; do echo \"--- $f -------------\"; ./e <$f; done"
 * end:
 */


Measured memory_bytes: 7944
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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() {
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll>a(n);
    vector<ll>b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    vector<ll>s(m+1);
    rep(i,m) s[i+1] = s[i] + b[i];
    ll sum = 0;
    ll ret = 0;
    for(int i = 0;i<=a.size();i++) {
        if(i>0) sum += a[i-1];
        if(sum<=k) {
            ll pos = upper_bound(s.begin(),s.end(),k-sum) -s.begin()-1;
            chmax(ret,i+pos);
        }
    }
    cout << ret << endl;
}



Measured memory_bytes: 7988