akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int max = 0;
		for (int i = 1; i < N - 1; i++) {
			String X = S.substring(0, i);
			String Y = S.substring(i);
			int result = 0;
			int min = Math.min(X.length(), Y.length());
			for (int j = 0; j < 26 && result < min; j++) {
				char alphbet = (char) ((char)'a' + j);
				if (X.contains(String.valueOf(alphbet)) && Y.contains(String.valueOf(alphbet))) {
					result++;
				}
			}
			max = Math.max(max, result);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 27596
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
//
int main()
{

    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> P(N, 0);
    vector<ll> Q(N, 0);
    rep(i, N)
    {
        cin >> P[i];
    }
    rep(i, N)
    {
        cin >> Q[i];
    }

    //
    vector<ll> I(N);
    iota(I.begin(), I.end(), 1);
    ll cnt = 0;
    ll iP = -1, iQ = -1;
    do
    {
        if (I == P) iP = cnt;
        if (I == Q) iQ = cnt;
        ++cnt;
    } while (std::next_permutation(I.begin(), I.end()));

    cout << abs(iP - iQ);

    return 0;
}


Measured memory_bytes: 3232
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll a, b;
int main() {
  cin >> a >> b;
  if (a > 8 || b > 8) {
    cout << ":(" << endl;
    return 0;
  }
  cout << "Yay!" << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    string r;cin>>r;
    string s = r;
    reverse( all(r) );

    int ans = 0;
    rep(i,s.size()){
        if(r[i] != s[i])ans++;
    }
    ans /= 2;
    cout << ans << endl;

    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, vector<long long> A){
    int ok = 0;
    ll allvote = accumulate(A.begin(), A.end(), 0);
    double thld;
    rep(i, N) {
        thld = allvote / (4.0*M);
        ok += int(A[i] >= thld);
    }

    if (ok >= M) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    cin >> N;
    long long M;
    cin >> M;
    vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        cin >> A[i];
    }
    solve(N, M, move(A));
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    int nax=-1,nin=99999999;
    
    for(int i=0;i<n;i++){
        int hoge;
        cin>>hoge;
        
        nax=max(nax,hoge);
        nin=min(nin,hoge);
    }
    
    cout<<nax-nin<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    char s[3];
    char t[3];
    scanf("%s",s);
    scanf("%s",t);
    
    
    
int ans=0,i;
for(i=0;i<3;i++){
    if(s[i]==t[i]){ans++;}
}

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

Measured memory_bytes: 128
n = gets.chomp.to_i
h = []
h = gets.chomp.split.map(&:to_i)
ans = 'Yes'
max = 0
idx = 0
h.each_with_index do |elem, i|
  if elem + 1 < max
    ans = 'No'
    break
  end

  if max < elem
    max = elem
    idx = i
  end
end
puts ans

Measured memory_bytes: 9604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
map<int,int>mp;
signed main(){
	cin>>N;
	rep(i,N){
		int a;cin>>a;mp[a]++;
	}
	if(mp.size()==1){
		if(mp[0]==N)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		return 0;
	}
	if(N%3||mp.size()>3){
		cout<<"No"<<endl;return 0;
	}
	if(mp.size()==2){
		if(mp[0]==N/3)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}else if(mp.size()==3){
		int res=0;
		for(auto p:mp){
			if(p.second!=N/3){
				cout<<"No"<<endl;return 0;
			}
			res^=p.first;
		}
		if(!res)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

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

int main() {
    int N, A, B; cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    string S; cin >> S;
    for(int i=0;i<S.size();i++){
        char tmp = S[i]+N;
        if(tmp>'Z'){
            tmp = tmp - 26;
        }
        printf("%c",tmp);
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 510
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

LL T,n,i,j,k,x,y,z;
LL a[N],f[N];
char c[N];

IL int Abs(int x){return (x<0)?-x:x;}
IL void Swap(int &a,int &b){a^=b^=a^=b;}
IL int Min(int a,int b){return (a<b)?a:b;}
IL LL Max(LL a,LL b){return (a>b)?a:b;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL LL read(){
	LL p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	for (i=1;i<=n;i++)	a[i]=read();
	f[1]=1000;
	for (i=2;i<=n;i++){
		for (j=1;j<i;j++)	f[i]=Max(f[i],f[j]);
		for (j=1;j<i;j++){
			f[i]=Max(f[i],f[j]/a[j]*a[i]+f[j]%a[j]);
		}
	}
	cout<<f[n]<<endl;
	return 0;
}

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

using namespace std;

const int N = 100005;

int n , q , a , b;
int v[N];
bool ok[N];

int main()
{
    int curent = 1 , i;

    cin >> n >> q;

    ok[1] = ok[2] = 1;

    for(i = 1 ; i <= n ; i++)
        v[i] = i;

    for(i = 1 ; i <= q ; i++)
    {
        cin >> a >> b;

        if(curent == a)
            curent = b;
        else if(curent == b)
            curent = a;

        swap(v[a] , v[b]);

        if(curent > 1)
            ok[ v[curent - 1] ] = 1;

        if(curent < n)
            ok[ v[curent + 1] ] = 1;

        ok[ v[curent] ]= 1;
    }

    cout << count(ok + 1 , ok + n + 1 , 1);

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

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

ll calcWithMFR(string formula) {
  ll first_num = 1, second_num = 0;
  for (int i = 0; i < formula.size(); i++) {
    if (formula[i] == '*') {
      first_num *= second_num;
      second_num = 0;
      continue;
    } else if (formula[i] == '+') {
      return first_num * second_num + calcWithMFR(formula.substr(i+1));
    }
    int num = (int)(formula[i] - '0');
    if (second_num == 0) {
      second_num = num;
    } else {
      second_num = second_num * 10 + num;
    }
  }
  first_num *= second_num;
  return first_num;
}

ll calcWithLRR(string formula) {
  ll last_num = 0;
  for (int i = formula.size() - 1; i >= 0; i--) {
    if (formula[i] == '*') {
      return calcWithLRR(formula.substr(0, i)) * last_num;
    } else if (formula[i] == '+') {
      return calcWithLRR(formula.substr(0, i)) + last_num;
    }
    int num = (int)(formula[i] - '0');
    last_num += pow(10.0, (double)(formula.size() - i - 1)) * num;
  }
  return last_num;
}

int main() {
  string formula;
  cin >> formula;
  ll a;
  cin >> a;
  if (calcWithMFR(formula) == a && calcWithLRR(formula) == a) {
    cout << "U" << endl;
  } else if (calcWithMFR(formula) == a) {
    cout << "M" << endl;
  } else if (calcWithLRR(formula) == a) {
    cout << "L" << endl;
  } else {
    cout << "I" << endl;
  }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()>k){
        string tmp = s.substr(0, k);
        tmp += "...";
        cout<<tmp<<endl;
    }
    else cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3596
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;

int main(){
    fastio
    string s ; 
    cin >> s ;
    map<char,int> m ; 
    for(char c : s){
    	m[c]++ ; 
    }
    if ( m.size() != 2 ){
    	cout << "No" << endl;
    	return 0 ; 
    }
    for(auto p : m){
    	if ( p.second != 2 ){
    		cout << "No" << endl;
    		return 0 ; 
    	}
    }
    cout << "Yes" << endl;
    return 0 ;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class listint
{
    public int rec { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int p = int.Parse(input[1]);

        int ret = ((3 * a) + p) / 2;

        //出力
        Console.WriteLine(ret);
    }
}

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

int main(){
  int x, y, a, b;
  cin>>x>>y;
  a=max(x, y);
  b=min(x, y);
  while(b != 0){
    int r = a;
    a = b;
    b = r % b;
  }
  cout<<a<<endl;
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h> 
using namespace std; 
#include <stack>
#define ll long long 
const ll INF=1000000007;
#define vecpair vector<pair <ll,ll> >
#define pb push_back
#define mp make_pair
#define vel vector<ll>
#define endl "\n"
#define forl for(int i=0;i<n;i++)
const ll MAXN=1000001;
bool prime[1000001];
void SieveOfEratosthenes() 
{ 
    // 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.  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=1000000; 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<=1000000; i += p) 
                prime[i] = false; 
        } 
    } 
  
    
} 
ll bs(vel a,ll s,ll e,ll x){
	int l=s;
	int h=e;
	int m;
	while(l<=h){
		m=(l+h)/2;
		if(a[m]>x) h=m-1;
		else if(a[m]<x) l=m+1;
		else return m;
		}
		return -1;
	}

ll mex(vel a,int n){
	sort(a.begin(),a.end());
	int j=a[0];
	if(j!=0) return 0;
	else{
		for(int i=1;i<n;i++){
				if(a[i]!=a[i-1]){
					if(a[i]!=a[i-1]+1){
						return j+1;
						}else j++;
					}
			}
			return j+1;
		}
}

int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

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

ll c(ll m,ll n){
	ll ans=1;
	for(int i=1;i<=n;i++){
		ans=(ans*(m-i+1))/i;
		}
		return ans;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll test;
test=1;
while(test--){
ll n,x,t;
cin>>n>>x>>t;
if(n%x==0) cout<<t*(n/x)<<endl;
else cout<<t*(n/x + 1)<<endl;
}
}


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

int main()
{
    /* INPUT */
    long long N, K;
    std::cin >> N >> K;
    std::vector<double> p(N);

    for (int i = 0; i < N; i++)
        std::cin >> p[i];

    /* SOLVE */
    // std::vector<long long> sum_k(N-K+1);
    // for (int i = 0; i < sum_k.size(); i++)
    //     sum_k[i] = 0;

    // for (int i = 0; i <= N - K; i++)
    // {
    //     for (int j = i; j < i + K; j++)
    //     {
    //         sum_k[i] += p[j];
    //     }
    // }

    // for (int i = 0; i < sum_k.size(); i++)
    //     std::cout << sum_k[i] << " ";
    // std::cout << std::endl;

    // std::vector<long long>::iterator iter = std::max_element(sum_k.begin(), sum_k.end());
    // size_t max_index = std::distance(sum_k.begin(), iter);
    // std::cout << "max index: " << max_index << std::endl;

    int max_ind = -1;
    int accm_max = -1;
    int accm = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cnt++;
        if (cnt < K)
            accm += p[i];
        else if (cnt == K)
        {
            accm += p[i];
            if (accm > accm_max)
            {
                accm_max = accm;
                max_ind = i;
            }
        }
        else if (cnt > K)
        {
            accm -= p[i-K];
            accm += p[i];
            if (accm > accm_max)
            {
                accm_max = accm;
                max_ind = i;
            }
        }
    }
    //std::cout << "max ind: " << max_ind << std::endl;

    double ans = 0;
    double exp_num = 0;
    for (int i = max_ind; i > max_ind - K; i--)
    {
        exp_num = (p[i] * (p[i]+1)) / 2 / p[i];
        ans += exp_num;      
    }
    std::cout << std::fixed << std::setprecision(10) << ans << std::endl;

    // double ans = 0;
    // double exp_num = 0;
    // for (int i = max_index; i < max_index + K; i++)
    // {
    //     //std::cout << p[i] << std::endl;
    //     exp_num = (p[i] * (p[i]+1)) / 2 / p[i];
    //     ans += exp_num;
    // }
    // std::cout << std::fixed << std::setprecision(10) << ans << std::endl;

    return 0;
}

Measured memory_bytes: 1792
N, X = map(int, input().split())

# (i)XがLバーガーの半分より上かどうか？を計算
# (ii-i)上の場合: sumに下半分のパティの数を加算。下半分を切り捨てて、L-1バーガに対して、
#        再度X = (X-(Lバーガーの半分の枚数))で(i)から計算
# (ii-ii)下の場合: 上半分を切り捨てて、L-1バーガに対して再度X = (X-(Lバーガーの半分の枚数))で(i)から計算

patty_num_map = {}
size_map = {}
patty_num_map[0] = 1
size_map[0] = 1
for i in range(1, 51):
    patty_num_map[i] = 1+patty_num_map[i-1]*2
    size_map[i] = 3+size_map[i-1]*2

L = N
patty_sum = 0
L1_map = {}
L1_map[0] = 0
L1_map[1] = 0
L1_map[2] = 1
L1_map[3] = 2
L1_map[4] = 3
L1_map[5] = 3
L1_map[6] = 3
for i in range(7, 10000):
    L1_map[i] = 3
while True:
    half = size_map[L]//2+1
    if L < 2:
        patty_sum += L1_map[X]
        break
    if X > half:
        patty_sum += patty_num_map[L-1]+1  # 真ん中のpattyの分
        # X -= half+1  # 一番上のバティの分
        X -= half
        L -= 1
    elif X < half:
        X -= 1  # 一番下のバンの分
        L -= 1
    else:  # ちょうど半分
        patty_sum += patty_num_map[L-1]+1
        break
print(patty_sum)


Measured memory_bytes: 3896
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
N,X,Y = inputlist()
graph = [[] for _ in range(N+1)]
for i in range(1,N):
    graph[i].append(i+1)
    graph[i+1].append(i)
graph[X].append(Y)
graph[Y].append(X)
seen = [False]*(N+1)
ans = [0]*(N+1)
def bfs(i):
    from collections import deque
    que = deque()
    que.append([i,0])
    seen[i] = True
    while len(que)!=0:
        li = que.popleft()
        x = li[0]
        count = li[1]
        for j in graph[x]:
            if seen[j]:
                continue
            seen[j] = True
            counta= count + 1
            que.append([j,counta])
            ans[counta]+=1
for i in range(1,N+1):
    seen = [False]*(N+1)
    bfs(i)
for i in range(1,N):
    print(ans[i]//2)

Measured memory_bytes: 47836
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int N;
	cin>>N;
	long long int M;
	cin>>M;
	long long int V[N];
	long long int P[N];
	for(int i = 0 ;i<N;i++)
	{
		cin>>V[i];
		cin>>P[i];
	}
	long long int L[N+1][M+1];
	for(int i = 0 ;i<N+1;i++)
	{
		L[i][0] = 0;
	}
	for(int i = 0;i<M+1;i++)
	{
		L[0][i] = 0;
	}
	for(int i = 1;i<N+1;i++)
	{
		for(int j = 1;j<M+1;j++)
		{
			if(j-V[i-1]>=0)
			{
				L[i][j] = max(L[i-1][j], L[i-1][j-V[i-1]]+P[i-1]);
			}
			else L[i][j] = L[i-1][j];
		}
	}
	cout<<L[N][M];
}


Measured memory_bytes: 82296
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int n;
	cin >> n;
	vector<int> s(n);
	vector<int> a(n);
	REP(i,n){
		cin >> a[i];
		s[i] = a[i];
	}
	sort(s.begin(),s.end());
	
	REP(i,n){
		if(a[i] == s[n-1]) cout << s[n-2] << endl;
		else cout << s[n-1] << endl;
	}
	
	
	return 0;
}

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

pair<int,int> dfs(int node, int depth, vector<vector<int>>& edge, vector<int>& val){
    if(val[node] != -1) return {0,0};
    val[node] = depth%2;
    pair<int,int> ret{(depth%2 == 0?1:0), (depth%2 == 1?1:0)};
    for(auto &e: edge[node]){
        if(val[e] != -1) continue;
        auto res = dfs(e, depth+1, edge, val);
        ret.first += res.first;
        ret.second += res.second;
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> edge(n);
    vector<vector<int>> new_edge(n);
    int a,b;

    for(int i=0;i<n-1;i++){
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int f, s;
    vector<int> val(n, -1);
    tie(f,s) = dfs(0, 0, edge, val);
    cout << endl;
    int st[3] {1,2,3};
    if(f <= n / 3){
        for(int i=0;i<n;i++){
            if(val[i] == 0){
                val[i] = st[2];
                st[2] += 3;
            }else{
                int tar = (st[0] < st[1]?0:1);
                tar = (st[tar] <= n?tar:2);
                val[i] = st[tar];
                st[tar] += 3;
            }
        }
    }else if(s <= n / 3){
        for(int i=0;i<n;i++){
            if(val[i] == 1){
                val[i] = st[2];
                st[2] += 3;
            }else{
                int tar = (st[0] < st[1]?0:1);
                tar = (st[tar] <= n?tar:2);
                val[i] = st[tar];
                st[tar] += 3;
            }
        }
    }else{
        for(int i=0;i<n;i++){
            if(val[i] == 0){
                int tar = (st[0] <= n?0:2);
                val[i] = st[tar];
                st[tar] += 3;
            }else{
                int tar = (st[1] <= n?1:2);
                val[i] = st[tar];
                st[tar] += 3;
            }
        }
    }
    for(int i=0;i<n;i++)
        cout << val[i] << " ";
    cout << endl;
}



Measured memory_bytes: 25728
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    int i;
    long long int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<long long>v;
    for(i=0;i<n;i++)
    {
        v.push_back(a[i]-i-1);
    }
    sort(v.begin(),v.end());
    int g=v.size()/2;
    long long ans=v[g];
    long long ans1=0;
    for(i=0;i<v.size();i++)
    {
        ans1+=abs(v[i]-ans);
    }
    cout<<ans1<<endl;
}


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(C/B+(C%B>0) > A/D+(A%D>0)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3632
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

s = ni()

def collatz(x, i):
    if x <= 1:
        return i
    if x % 2 == 0:
        return collatz(x / 2, i + 1)
    else:
        return collatz(3 * x + 1, i + 1)

if s <= 2:
    print(4)
else:
    print(collatz(s, 1) + 1)

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

int main() {
    
    int N;
    cin >> N;
    
    vector<string> s(N);
    for (int i = 0; i < N; i++)
    {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    sort(s.begin(), s.end());

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

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


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 100 + 3, inf = 1e9 + 10;
string s[sz];
int dp[sz][sz];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> s[i];

	dp[0][0] = s[0][0] == '#';
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {

			if (i + j > 0) {
				dp[i][j] = inf;
				if (i > 0)dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i][j] == '#' && s[i - 1][j] == '.'));
				if (j > 0)dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] == '.'));
			}
		}
	}
	cout << dp[n - 1][m - 1] << "\n";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a_list(n);
    vector<int> kaburi(1e6+10),seen(1e6+10);
    for (int i = 0; i < n; i++ ) {
        cin >> a_list.at(i);
        kaburi.at(a_list.at(i))++;
    }
    sort(a_list.begin(),a_list.end());
    bool dp[int(1e6+10)] = {};
    for (int i = 0; i < int(1e6+10); i++) {
        dp[i] = 1;
    }

    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (kaburi.at(a_list.at(i)) >= 2) {
            if (seen.at(a_list.at(i)) == 1) continue;
            else {
                seen.at(a_list.at(i)) = 1;
            }
        }
        else {
            if (dp[a_list.at(i)] == 1){
                ans++;

            }
                
        } 
        for (int j = a_list.at(i); j < int(1e6+10); j += a_list.at(i)) {
            dp[j] = 0;   

        }
         
        
    }
cout << ans << endl;
}

Measured memory_bytes: 12756
#include<bits/stdc++.h>
#define   ll  long long int
#define   sz  100100

using namespace std;

string ss[sz];


string tani(ll n,char ch)
{
    ll i;
    string s="";

    for(i=1;i<=n;i++)s+=ch;

    return s;

}
int main()
{

    string s="abcdefghijklmnopqrstuvwxyz";

    ll i,j,k,p,x,d,c,a,b,n;

    string an="";

    cin>>n;

    ll mn=10000000;


    for(i=1;i<=n;i++)
    {
        cin>>ss[i];
    }

    for(i=0;i<26;i++)
    {
        mn=10000000;

        for(j=1;j<=n;j++)
        {
            c=0;

            for(k=0;k<ss[j].size();k++)
            {
                if(ss[j][k]==s[i])c++;
            }
            mn=min(mn,c);
        }

        string xx=tani(mn,s[i]);

        an+=xx;
    }

    cout<<an<<endl;

    return 0;
}



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

int a[3][3];
int b[11];
int n;
bool found[102];

bool check(int r, int c, int i, int j) {
	for (int k = 0; k < 3; k++, r += i, c += j) {
		if (!found[a[r][c]])
			return false;
	}
	return true;
}

int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		found[b[i]] = 1;
	}
	if (check(0, 0, 1, 1) || check(2, 0, -1, 1)) {
		puts("Yes");
		return 0;
	}
	for (int i = 0; i < 3; i++) {
		if (check(i, 0, 0, 1) || check(0, i, 1, 0)) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))

    def pleaceAC():
        left = list(accumulate([0]+A, gcd))
        right = list(accumulate(reversed(A+[0]), gcd))
        for i in range(N):
            yield gcd(left[i], right[~(i+1)])

    print(max(pleaceAC()))


main()

Measured memory_bytes: 16148
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, res = 0;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  REP(i,n) cin >> v[i];
  REP(i,n) cin >> c[i];
  REP(i,n) {
    int a = v[i] - c[i];
    if(a > 0) res += a;
  }
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    ll n,m;cin>>n>>m;
    vector<ll> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    ll res=0,sum=0;
    map<ll,ll> mp;
    mp[0]++;
    for(int i=1;i<=n;i++){
        sum+=a[i]; sum%=m;
        res += mp[sum];
        mp[sum]++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

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

	string akiba = "AKIHABARA";

	for(int i = s.size() - 1; i >= 0; i--){
		if(i == s.size() - 1 && s[i] != 'A')
			s.insert(s.end(), 'A');
		if(s[i] == 'B' && s[i + 1] != 'A')
			s.insert(s.begin() + i + 1, 'A');
		if(s[i] == 'H' && s[i + 1] != 'A')
			s.insert(s.begin() + i + 1, 'A');
		if(i == 0 && s[i] != 'A')
			s.insert(s.begin() + i, 'A');

	}

	cout << (akiba == s ? "YES" : "NO") << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int N, A, B, i, j, sum, ans=0;

    cin >> N >> A >> B;

    for(i=1; i<=N; i++){
        j = i;

        sum = 0;

        while(j!=0){
            sum += (j%10);

            j /= 10;
        }

        if(A<=sum && sum<=B){
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
public class Test
{
    public static void Main(string[] vs)
    {
        switch(Console.ReadLine())
        {
            case "A":
                Console.WriteLine("T");
                break;
            case "T":
                Console.WriteLine("A");
                break;
            case "C":
                Console.WriteLine("G");
                break;
            case "G":
                Console.WriteLine("C");
                break;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 2100000000
#define MOD 1000000007

int main(){
  int N;
  cin>>N;
  vector<ll> A(N),B(N),diff(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<N;i++){
    diff.at(i)=A.at(i)-B.at(i);
  }
  sort(diff.begin(),diff.end());
  ll sum=0;
  for(int i=0;i<N;i++){
    sum+=diff.at(i);
  }
  if(sum<0){
    cout<<-1<<endl;
  }else{
    int i=0;
    int ans=0;
    ll minus=0;
    while(diff.at(i)<0){
      minus+=diff.at(i);
      i++;
    }
    ans=i;
    i=N-1;
    while(minus<0){
      minus+=diff.at(i);
      ans++;
      i--;
    }
    cout<<ans<<endl;

  }

}


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

tmpW = input()
past = set()
past.add(tmpW)
flag = True
for i in range(N - 1):
    W = input()
    if(tmpW[-1:] != W[0:1]):
        flag = False
    elif(W in past):
        flag = False
    tmpW = W

    past.add(W)
    # print(past)

if(flag is True):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
A,B,C,D = map(int, input().split())
def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y % x, x)
def lcm(x,y):
    return x * y // gcd(x,y)
L = lcm(C,D)
b = B - (B // C) - (B // D) + (B // L)
a = (A-1) - ((A-1) // C) - ((A-1) // D) + ((A-1) // L)
print(b - a)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#include <math.h> 

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void){
    // Your code here!
    int n,num,count;
    cin >> n;
    count = 0;

    for(int i=0;i<n;i++){
        cin >> num;
        if(IsPrime(num)) count++;    
    }
    cout << count << endl;
    
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <map>
#include <utility>

using namespace std;

int main() {
    int n, tmp;
    vector<int> seq;
    map<int, bool> map;

    cin >> n;
    int max = 0;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (tmp > max)
            max = tmp;
        
        if (map.find(tmp) == map.end())
            map.insert(make_pair(tmp, false));
        else {
            map.erase(tmp);
            map.insert(make_pair(tmp, true));
        }
    }

    for (auto it = map.begin(); it != map.end(); it++) {
        int multiplicand = it->first;
        int multiplier = 2;
        int multiplied = multiplicand * multiplier;
        while (multiplicand * multiplier <= max) {
            auto found = map.find(multiplied);

            if (found == map.end()) {
                multiplier++;
                multiplied = multiplicand * multiplier;
                continue;
            } else {
                map.erase(multiplied);
                map.insert(make_pair(multiplied, true));
                multiplier++;
                multiplied = multiplicand * multiplier;
            }
        }
    }
    
    int count = 0;
    for (auto it = map.begin(); it != map.end(); it++) {
        if (!it->second)
            count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 12956
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8').split(' ');
const a = +input[0]
const b = +input[1]
const c = +input[2]
const k = +input[3]
if (k <= a) {
  console.log(k);
} else if (k <= a + b) {
  console.log(a);
} else {
  console.log(a - (k - a - b));
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    c=c-a;
    d=d-b;
    a=0;
    b=0;
    for (int i=0;i<d;i++){
        cout<<'U';
    }for (int i=0;i<c;i++){
        cout<<'R';
    }for (int i=0;i<d;i++){
        cout<<'D';
    }for (int i=0;i<=c;i++){
        cout<<'L';
    }for (int i=0;i<=d;i++){
        cout<<'U';
    }for (int i=0;i<=c;i++){
        cout<<'R';
    }cout<<"DR";
    for (int i=0;i<=d;i++){
        cout<<'D';
    }for (int i=0;i<=c;i++){
        cout<<'L';
    }cout<<'U';
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
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 S(): return input().rstrip()
def LS(): return S().split()
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 = 1e10

#solve
def solve():
    n, h, w = LI()
    ab = LIR(n)
    ans = 0
    for a, b in ab:
        if a >= h and b >= w:
            ans += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39408
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	for(auto &c: s){
		if(c == '?'){
			c = 'D';
		}
	}
	cout << s;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

using namespace std;

typedef long long ll;

bool isValid(int x,int y,int X,int Y){
    if((x>=1 && x<=X) && (y>=1 && y<=Y)){
       return true; 
    }
    return false;
}

int main(){
    int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
    int h,w;
    cin>>h>>w;
    int sx,sy;
    cin>>sx>>sy;
    int ex,ey;
    cin>>ex>>ey;
    char maze[h+1][w+1];
    bool vis[h+1][w+1];
    for(int i=1;i<=h;i++){
        string s;
        cin>>s;
        for(int j=1;j<=w;j++){
            maze[i][j]=s[j-1];
        }
    }
    int dis[h+1][w+1];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            dis[i][j]=INT_MAX;
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            vis[i][j]=false;
        }
    }
    deque<pair<int,int>> d;
    dis[sx][sy]=0;
    d.push_back({sx,sy});
    while (!d.empty())
    {
        pair<int,int> cur=d.front();
        d.pop_front();
        int cx=cur.first;
        int cy=cur.second;
        vis[cx][cy]=true;
        int nx,ny;
        for(int i=0;i<4;i++){
            nx=cx+dir[i][0];
            ny=cy+dir[i][1];
            if(isValid(nx,ny,h,w) && maze[nx][ny]=='.' && !vis[nx][ny] && dis[cx][cy]<dis[nx][ny]){
                dis[nx][ny]=dis[cx][cy];
                d.push_front({nx,ny});
            }
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                nx=cx+i;
                ny=cy+j;
                if(isValid(nx,ny,h,w) && maze[nx][ny]=='.' && !vis[nx][ny] && dis[cx][cy]+1<dis[nx][ny]){
                    dis[nx][ny]=dis[cx][cy]+1;
                    d.push_back({nx,ny});
                }
            }
        }
    }
    if(dis[ex][ey]==INT_MAX){
        cout<<"-1";
    }
    else{
        cout<<dis[ex][ey];
    }
    return 0;
}

Measured memory_bytes: 9516
MOD = 10**9+7

N = int(input())

#0がまだどっちもでてない 1が0だけでてる　2が9だけ出てる　3が両方出た
dp = [[0 for i in range(4)]for j in range(N)]
dp[0] = [8,1,1,0]

for i in range(1,N):
    dp[i][0]=(dp[i-1][0]*8)%MOD
    dp[i][1]=((dp[i-1][1]*9)%MOD + dp[i-1][0])%MOD
    dp[i][2]=((dp[i-1][2]*9)%MOD + dp[i-1][0])%MOD
    dp[i][3]=(dp[i-1][1]+dp[i-1][2]+dp[i-1][3]*10)%MOD

print(dp[N-1][3])

Measured memory_bytes: 203044
#include <stdio.h>

int main(void)
{
  int w[31]; // w[0] is line number.
  int n;
  int buf[2], temp;
  int i;

  scanf("%d", &w[0]);
  scanf("%d", &n);

  for (i = 1; i <= w[0]; i++) {
    w[i] = i;
  }

  for (i = 0; i < n; i++) {
    scanf("%d,%d", &buf[0], &buf[1]);
    temp = w[buf[0]];
    w[buf[0]] = w[buf[1]];
    w[buf[1]] = temp;
  }

  for (i = 1; i <= w[0]; i++) {
    printf("%d\n", w[i]);
  }

  return 0;
}

Measured memory_bytes: 596
s=input()
l=len(s)
d=[0]*l
c="R"
b=0
a=0
e=0
for i in range(l):
  if c=="R":
    if s[i]=="R":b+=1
    else:
      a=i-1
      c=s[i]
      e=b
      b+=1
  elif c=="L":
    if s[i]=="R":
      if e%2==0:
        d[a]=b//2
        d[a+1]=0--b//2
      else:
        d[a]=0--b//2
        d[a+1]=b//2
      b=1
      c=s[i]
    else:b+=1
if e%2==0:
  d[a]=b//2
  d[a+1]=0--b//2
else:
  d[a]=0--b//2
  d[a+1]=b//2
print(*d)

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

int n,m,isok,du[N];

int main(){
#ifdef rqgao2014
//	freopen("input.txt","r",stdin);
	srand(time(0));
	time_tester(0);
#endif
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		du[x]++;du[y]++;
	}
	for(int i=1;i<=n;i++)
	if(du[i]&1){puts("NO");return 0;}
	puts("YES");
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;
typedef int64_t ll;
const ll INF = 1000000000000000000;


int main() {
	double x, t;
	cin >> x >> t;
	cout << x / t << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int eval(int w, int h, int x, int y, int r){
    if (x-r < 0) return 0;
    if (y-r < 0) return 0;
    if (x+r > w) return 0;
    if (y+r > h) return 0;
    return 1;
}
int main(){
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    int ret = eval(w, h, x, y, r);
    if (ret)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 584
n, m, x, y = map(int, input().split())
xMax = max(map(int, input().split()))
yMin = min(map(int, input().split()))
swi = "No War"

if yMin < xMax+1:
    swi = "War"
else:
    for i in range(xMax+1, yMin+1):
        if not(x+1 <= i <= y):
            swi = "War"
            break
print(swi)


Measured memory_bytes: 3060
list = []
while True:
    t1, t2 = map(int, input().split())
    if t1 == 0 and t2 == 0:
        break
    list.append([t1, t2])

for i in range(len(list)):
    if list[i][0] > list[i][1]:
        tmp = list[i][0]
        list[i][0] = list[i][1]
        list[i][1] = tmp


for i in range(len(list)):
    print(" ".join(map(str, list[i])))


Measured memory_bytes: 6016
#include <stdio.h>
#include <stdlib.h>
int compare(const int* a, const int* b)
{
	return *a - *b;
}
int main(void)
{
	int n;
	scanf("%d", &n);
	int* input = (int*)malloc(n * sizeof(int));
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &input[i]);
	}
	qsort(input, n, sizeof(int), compare);
	int flag = 1;
	for (int i = 1; i < n; i++)
	{
		if (input[i] == input[i - 1])
		{
			flag = 0;
			break;
		}
	}
	printf("%s", flag ? "YES" : "NO");
}

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int a[3][3],b[10];
  bool aa[3][3],ans=false;
  int n;

  rep(i,0,3)
  rep(j,0,3){
    cin>>a[i][j];
    aa[i][j]=false;
  }

  cin>>n;
  rep(i,0,n) cin>>b[i];

  rep(k,0,n){
    rep(i,0,3)
    rep(j,0,3){
      if(a[i][j]==b[k]) aa[i][j]=true;
    }
  }

  rep(i,0,3){
    if((aa[i][0] && aa[i][1]) && aa[i][2]) ans=true;
    else if((aa[0][i] && aa[1][i]) && aa[2][i]) ans=true;

    if((aa[0][0] && aa[1][1]) && aa[2][2]) ans=true;
    if((aa[0][2] && aa[1][1]) && aa[2][0]) ans=true;
    }

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



}

Measured memory_bytes: 256