akhauriyash/Code-Regression huggingface dataset:
N = int(input())
happy = [[0 for _ in range(3)] for _ in range(N)]
for n in range(N):
  happy[n] = list(map(int, input().split()))

dp = [[0 for _ in range(3)] for _ in range(N)]
for i in range(3):
  dp[0][i] = happy[0][i]
for n in range(1,N):
  for i in range(3):
    dp[n][i] = max(dp[n-1][:i] + dp[n-1][i+1:]) + happy[n][i]
print(max(dp[-1]))

Measured memory_bytes: 47280
N=int(input())
C0=0
C1=0
C2=0
C3=0
for i in range(N):
    S=input()
    if S=='AC':
        C0+=1
    elif S=='WA':
        C1+=1
    elif S=='TLE':
        C2+=1
    else:
        C3+=1
print("AC x " + str(C0))
print("WA x "+str(C1))
print("TLE x "+str(C2))
print("RE x "+str(C3))

Measured memory_bytes: 9204
#include<stdio.h>

int main(){
	int n,i,anss[100010]={0},c=1,si[100010]={0};
	char s[100010],t[100010];
	scanf("%s",s);
	for(i=0;s[i]!=0;i++);
	n=i;t[1]=s[0];si[1]=0;
	for(i=1;i<n;i++){
		if(s[i]!=s[i-1]){
			t[++c]=s[i];
			si[c]=i;
		}
	}si[c+1]=n;
	int tmp=0;
	for(i=1;i<=c;i++){
		if(s[si[i]]=='R'){
			anss[si[i+1]-1]+=(si[i+1]-si[i]+1)/2;
			anss[si[i+1]]+=(si[i+1]-si[i])/2;
		}if(s[si[i]]=='L'){
			anss[si[i]-1]+=(si[i+1]-si[i])/2;
			anss[si[i]]+=(si[i+1]-si[i]+1)/2;
		}
	}
	for(i=0;i<n;i++)printf("%d ",anss[i]);
	puts("");
	return 0;
}


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

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

using namespace std;
using lint=long long;

template<class T> struct interval{
	T l,r;
	interval():l(T{}),r(T{}){}
	interval(const T& l,const T& r):l(l),r(r){}
	bool operator<(const interval& I)const{ return make_tuple(l,r)<make_tuple(I.l,I.r); }
};

template<class T>
vector<interval<T>> interval_union(vector<interval<T>> I){
	sort(I.begin(),I.end(),[](const interval<T>& a,const interval<T>& b){ return a.l<b.l; });

	int n=I.size();
	if(n==0) return {};

	vector<interval<T>> Res;
	T l=I[0].l,r=I[0].r;
	for(int i=1;i<=n;i++){
		if(i==n || r<I[i].l){
			Res.emplace_back(l,r);
			if(i<n){
				l=I[i].l;
				r=I[i].r;
			}
		}
		else if(r<I[i].r){
			r=I[i].r;
		}
	}
	return Res;
}

lint all_or(lint a,lint b){
	for(int i=60;i>=0;i--) if((a>>i)<(b>>i)) return ((b>>i)<<i)|((1LL<<i)-1);
	return b;
}

int main(){
	lint a,b; cin>>a>>b;

	lint x=b;
	for(int i=60;i>=0;i--) if((a>>i)<(b>>i)) {
		x=(b>>i)<<i;
		break;
	}
	lint y=all_or(x,b);
	lint z=all_or(a,b);

	lint ans=0;
	for(auto J:interval_union(vector<interval<lint>>{{a,y+1},{a|x,z+1}})) ans+=J.r-J.l;
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    min_change = 100000000

    S = [s for s in S]
    T = [t for t in T]

    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if j == 0:
                c = 0
            if len(S) <= i + j:
                break
            if S[i+j] != t:
                c += 1
            if len(T) == j + 1:
                min_change = min(min_change, c)

    print(min_change)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


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

using namespace std;

 
int main() {
     int n;
     string ans = "APPROVED";

     cin >> n;

     

     
    int num;
     for(int i = 0;i < n ;i++){
         cin >> num;
         if(num % 2 == 0 && (num %3 != 0 && num % 5 != 0)){
             ans = "DENIED";
             break;
         }
     }

     cout << ans;
     

    }
   


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

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        long i = 0;

        for(i = 1; i < 1000; i++)
        {
            if (i * 1000 >= n) break;
        }

        Console.WriteLine((1000 * i) - n);
    }
}

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

int main(){
    int n;cin>>n;
    vector<vector<int>> v(n,vector<int>(3));
    for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>v[i][j];
    vector<vector<int>> dp=v;
    int maxi=max(dp[0][0],max(dp[0][1],dp[0][2]));
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            dp[i][j]+=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
             maxi=max(maxi,dp[i][j]);
        }
       
    }
    cout<<maxi<<endl;
    
}

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

const int maxn = 2e5 + 5;

long long sum[maxn], f[maxn], cnt;

struct node
{
	long long a, b;
} e[maxn];

inline bool cmp(node x, node y)
{
	return y.a * (x.b + 1) < x.a * (y.b + 1);
}

int main()
{
	ios::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	for (int i = 1; i <= 35; i++)
		f[i] = t + 1;
	for (int i = 1; i <= n; i++)
	{
		int x, y;
		cin >> x >> y;
		if (x == 0)
			sum[++cnt] = y + 1;
		else
			e[i - cnt].a = x, e[i - cnt].b = y;
	}
	n -= cnt;
	sort(e + 1, e + n + 1, cmp);
	sort(sum + 1, sum + cnt + 1);
	for (int i = 1; i <= cnt; i++)
		sum[i] += sum[i - 1];
	for (int i = 1; i <= n; i++)
		for (int j = 35; j >= 1; j--)
			f[j] = min(f[j], (f[j - 1] + 1) * (e[i].a + 1) + e[i].b);
	long long ans = 0;
	for (long long i = 0; i <= 35; i++)
	{
		if (f[i] > t)
			continue;
		int s = 0;
		if (cnt)
			s = upper_bound(sum + 1, sum + cnt + 1, t - f[i]) - (sum + 1);
		ans = max(ans, i + s);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6756
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int over = 0;
	int count[8] = { 0 };
	int ans = 0;
	int N, a;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a >= 3200) over++;
		else count[a / 400]++;
	}
	for (int i = 0; i < 8; i++) {
		if (count[i] != 0) ans++;
	}
	if (ans == 0) cout << 1 << " " << ans + over << endl;
	else cout << ans << " " << ans + over << endl;
}


Measured memory_bytes: 256
word = list(map(int,input().split()))
dlist = [0]*word[1]
Alist = [0]*word[1]
for i in range(word[1]):
    dlist[i] = int(input())
    Alist[i] = list(map(int,input().split()))

ninzu = [0]*word[0]
for j in range(word[1]):
    for k in range(dlist[j]):
        ninzu[Alist[j][k]-1] += 1
        
print(ninzu.count(0))

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

struct StNumCnt
{
  StNumCnt() : m_nNum(0), m_nCnt(0) { }

  int m_nNum;
  int m_nCnt;
};

bool greater_nCnt(const StNumCnt& lhs, const StNumCnt& rhs)
{
  return lhs.m_nCnt > rhs.m_nCnt;
}

void fnInput(vector<int>& rvnNum)
{
  int nNumSiz;
  cin >> nNumSiz;
  rvnNum.resize(nNumSiz);

  for (int& rnNum : rvnNum)
    cin >> rnNum;
}

int fnMinChangeCnt(const vector<int>& cnrvnNum)
{
  map<int, int> mpNumCntEvn, mpNumCntOdd;

  for (int i = 0; i < cnrvnNum.size(); ++i)
    if ( i % 2 == 0 )
      mpNumCntEvn[ cnrvnNum[i] ]++;
    else
      mpNumCntOdd[ cnrvnNum[i] ]++;

  vector<StNumCnt> voNumCntEvn( mpNumCntEvn.size() ),
                   voNumCntOdd( mpNumCntOdd.size() );

  int n = 0;
  for (pair<int, int> PNumCnt : mpNumCntEvn)
  {
    voNumCntEvn[n].m_nNum   = PNumCnt.first;
    voNumCntEvn[n++].m_nCnt = PNumCnt.second;
  }

  n = 0;
  for (pair<int, int> PNumCnt : mpNumCntOdd)
  {
    voNumCntOdd[n].m_nNum   = PNumCnt.first;
    voNumCntOdd[n++].m_nCnt = PNumCnt.second;
  }

  sort(begin(voNumCntEvn), end(voNumCntEvn), greater_nCnt);
  sort(begin(voNumCntOdd), end(voNumCntOdd), greater_nCnt);

  int nMinChangeCnt = INT_MAX;

  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      if (voNumCntEvn[i].m_nNum != voNumCntOdd[j].m_nNum)
        nMinChangeCnt = 
          min( nMinChangeCnt, 
               (int)cnrvnNum.size() - voNumCntEvn[i].m_nCnt - voNumCntOdd[j].m_nCnt );

  return nMinChangeCnt;
}
  
int main()
{
  vector<int> vnNum;
  
  fnInput(vnNum);
  cout << fnMinChangeCnt(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 8984
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datL) = readLine.split(" ").map(_.toInt)
    val datS = for(i <- 1 to datN) yield (readLine.split(" ").head)

    val ans = datS.sorted.mkString
    println(ans)
  }
}


Measured memory_bytes: 27320
N,M,X = map(int, input().split())
A = [int(a) for a in input().split()]

p = 0
for i in range(1, X):
    if i in A:
        p += 1

q = 0
for i in range(X+1, N):
    if i in A:
        q += 1

print(min(p, q))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k[3],n;
  cin>>k[0]>>k[1]>>k[2]>>n;
  sort(k,k+3);
  reverse(k,k+3);
  int b=k[0];
  for(int i=0;i<n;i++){
    b*=2;
  }
  cout<<b+k[1]+k[2]<<endl;
}


Measured memory_bytes: 256
#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;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1000000007;

int main(void){
    int n;
    cin >> n;
    VVL dp(n, VL(n + 1));
    dp[0][0] = 1;
    REP(i,n-1){
        ll s = 0;
        REP(j,n+1){
            if (j >= 3) s = (s + dp[i][j - 3]) % mod;
            dp[i + 1][j] = s;
        }
    }
    ll ans = 0;
    REP(i,n) ans = (ans + dp[i][n]) % mod;
    cout << ans << endl;

    return 0;
}


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

int main(){
    ll X; cin >> X;
    ll A = -999,B = -999;
    for(int a = -200; a<=200; a++){
        for(int b = -200; b<=200; b++){
            if(pow(a,5) - pow(b,5) == X){
                A = a; B = b;
            }
        }
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 4036
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}



int main(){
  int n, k;
  cin>>n>>k;
  vector<ll> v(n,0);

  rep(i,k) {
    int d;
    cin>>d;
    rep(j,d) {
      ll x;
      cin>>x;
      v[x-1]=1;
    }
  }
  ll ans = 0;
  rep(i,n)
    if(v[i]==0) ans++;
  std::cout << ans << std::endl;
  return 0;
}



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M){
    if(N == 1) {
        cout << M << endl;
        return;
    }
    LL ans = 1LL;
    for(LL i=1; i*N<=M; i++){
        if((M - (i*N)) % i == 0){
            ans = i;
        }
    }
 
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>> a(n);
    rep(i,n){
        cin>>a[i].first;
        a[i].second = i+1;
    }
    sort(a.begin(),a.end());
    rep(i,n){
        if(!i) printf("%lld",a[i].second);
        else printf(" %lld",a[i].second);
    }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
#define pii pair<int,int>
int main(){
    int h,w,m;
    cin >> h >> w >> m;
    map<int,int> xvec;
    map<int,int> yvec;
    map<pii,int> isthere; 
    int xmax,ymax;
    xmax = ymax = 0;
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        xvec[x]++;
        yvec[y]++;
        xmax = max(xmax,xvec[x]);
        ymax = max(ymax,yvec[y]);
        isthere[mp(x,y)]=1;
    }
    vector<int> x_candidate,y_candidate;
    for(auto x:xvec){
        if(x.second==xmax) x_candidate.push_back(x.first);
    }
    for(auto y:yvec){
        if(y.second==ymax) y_candidate.push_back(y.first);
    }
    bool fl = false;
    rep(i,x_candidate.size()){
        rep(j,y_candidate.size()){
            int nowx = x_candidate[i];
            int nowy = y_candidate[j];
            if(isthere[mp(nowx,nowy)]==0){
                fl = true;
                break;
            }
        }
        if(fl) break;
    }

    int ans;
    if(fl) ans = xmax+ymax;
    else ans = xmax+ymax-1;
    cout << ans << endl;
}

Measured memory_bytes: 54276
while True:
    try:
        a, b, c, d, e, f = map(float, input().split())
        x = (c*e - b*f)/(a*e - b*d)
        y = (a*f - c*d)/(a*e - b*d)
        if x == 0.0:
            x = abs(x)
        if y == 0.0:
            y = abs(y)
        print('%.3f %.3f' %(x,y))
    except:
        break

Measured memory_bytes: 7348
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  1000000007
#define ll long long
#define int long long
#define INF 1e18
#define ar array
#define MAX 1000004
#define wt(x) int x;cin>>x;while(x--)

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 
}
ll power(ll a,ll b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    ll res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 

 int32_t main() {

c_p_c();
int h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;
int tot1=(h1*60)+m1;
int tot2=(h2*60)+m2;
int rem=tot2-k;
cout<<abs(tot1-rem)<<"\n";

    

return 0;

}
 


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

int main()
{
	int ta=0;
	int top=0,se=0,sa=0;
	int dumy=0;

	for(int i=0;i<10;i++)
	{
		cin>>ta;
		if(ta>sa)
		{
			sa=ta;
		}
		if(sa>se)
		{
			dumy=se;
			se=sa;
			sa=dumy;
		}
		if(se>top)
		{
			dumy=top;
			top=se;
			se=dumy;
		}
		if(sa>se)
		{
			dumy=se;
			se=sa;
			sa=dumy;
		}
	}
	cout<<top<<endl;
	cout<<se<<endl;
	cout<<sa<<endl;

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


int main()
{
  string s,t;
  cin >> s >> t;
  ll ans = 0;
  REP(i,s.size()){
    if(s.at(i)!=t.at(i)){
      ans++;
    }
  }
  
  cout << ans << endl;
}

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

int c[300100];
int c2[300100];
int main()
{
	int n;string s;
	cin >> n >> s;
	
	int min = n;
	// 累積和を使う
	// c[0]は初期値で0とする
	// W の人が E を向かないといけない場合、リーダーの位置 i
	for( int i = 0; i < n; i++ ) {
		c[i+1] = c[i]; // リーダーが次の位置に移動すると、その前の累積和は必要
		if( s[i] == 'W' ) c[i+1]++; // 注目点が W ならリーダー移動時に加算
	}
	/*
	cout << " **** " << endl;
	for( int i = 0; i < n; i++ ) {
		cout << c[i] << " ";
	}
	cout << endl;
	*/
	// WE...E だったとすると c = { 0,1,1,....1(n)} となっている
	// E についても累積和 c を使えばいいが、デバックのため分ける
	//cout << " **** " << endl;
	for( int i = n; 0 < i; i-- ) {
		c2[i-1] = c2[i]; // リーダーが次の位置に移動すると、その前の累積和は必要
		if( s[i] == 'E' ) c2[i-1]++; // 注目点が W ならリーダー移動時に加算
	}
	/*
	for( int i = 0; i < n; i++ ) {
		cout << c2[i] << " ";
	}
	cout << endl;
	*/
	for( int i = 0; i < n; i++ ) {
		int one = c[i]+c2[i];
		if( one < min ) min = one;
	}
	cout << min << endl;
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

ll a,b,c;

int main(){
    cin >> a >> b >> c;
    int mind = min(a,b);
    int maxd = max(a,b);
    if(mind<=c&&c<=maxd){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef char keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

const int inf = 1012345678;
int main(){
    int n;
    int b[100];
    int a[100];

    scanf("%d", &n);
    for(int i = 0; i < (n - 1); ++i){
        scanf("%d", &b[i]);
    }

    int sum = b[0] + b[n-2];
    for(int i = 0; i < (n-2); ++i){
        sum += min(b[i], b[i+1]);
    }

    printf("%d\n", sum);

    return 0;
}


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

typedef long long int ll;

int main() {
	int k; cin >> k;
	queue<ll> q;
	
	for (ll i = 1; i <= 9; i++) q.push(i);
	
	for (int i = 0; i+1 < k; ++i) {
		ll v = q.front(); q.pop();
		if (v%10 != 0)
			q.push(10*v + v%10 - 1);
		q.push(10*v + v%10);
		if (v%10 != 9)
			q.push(10*v + v%10 + 1);
	}

	cout << q.front() << endl;
	
	return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

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

int main()
{
    ll n, ans =0;
    map<ll,ll> m;
    cin >> n;
    while(n--)
    {

        ll x;
        cin >> x;
        if(m[x]==0)
        {

            m[x]=1;
            ans++;
        }
        else if(m[x]==1)
        {

            ans--;
            m[x]=0;
        }
    }
    cout << ans;
}


Measured memory_bytes: 6528
// https://atcoder.jp/contests/abc084/tasks/abc084_d
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll Q;
    cin >> Q;
    vector<ll> l(Q), r(Q);
    REP(i, Q) cin >> l[i] >> r[i];
    vector<ll> isprime(100011, 0);
    size_t N = isprime.size();
    for (size_t n = 2; n < N; ++n)
    {
        if (isprime[n] == -1)
            continue;
        
        bool ok = true;
        for (size_t i = 2; i * i <= n; ++i)
        {
            if (n % i == 0)
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            isprime[n] = 1;
            for (size_t k = n + n; k < N; k += n)
            {
                isprime[k] = -1;
            }
        }
    }

    vector<ll> cnt(N, 0);
    for (size_t n = 3; n < N; n += 2)
    {
        if (isprime[n] == 1 && isprime[(n + 1) / 2] == 1)
        {
            cnt[n] = cnt[n - 2] + 1;
            cnt[n - 1] = cnt[n - 2];
        }
        else
        {
            cnt[n] = cnt[n - 2];
            cnt[n - 1] = cnt[n - 2];
        }
        
    }

    vector<ll> res(Q, 0);
    REP(i, Q)
    {
        res[i] = cnt[r[i]] - cnt[l[i] - 1];
    }
    
    REP(i, Q)
    {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7120
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define ll long long
#define name "frog1"
#define maxn 100005

using namespace std;

int n,k,h[maxn],a[maxn];

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

    cin>>n>>k;
    f(i,1,n)
    {
        cin>>h[i];
        a[i]=1000000009;
        fd(j,i-1,max(i-k,1))
        {
            a[i]=min(a[i],a[j]+abs(h[i]-h[j]));
        }
        if(i==1)
        {
            a[i]=0;
        }
    }
    cout<<a[n];


}


Measured memory_bytes: 4388
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if (n%2 == 0)
            System.out.println((n/2)*(n/2));
        else
            System.out.println((n/2)*((n/2)+1));
    }
}


Measured memory_bytes: 35648
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime> 
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MX = 1000005;

int N, A[MX];
int ps[MX];

vector<int> decompose(int a){
    vector<int> ans;
    if(a == 1) return ans;
    if(ps[a] == 0) {
        ans.push_back(a);
        return ans;
    }

    ans.push_back(ps[a]);
    int b = a;
    while(b % ps[a] == 0){
        b /= ps[a];
    }
    vector<int> cs = decompose(b);
    for(int c : cs){
        ans.push_back(c);
    }
    return ans;
}

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

void init(){
    memset(ps, 0, sizeof(ps));
    ps[1] = 1;
    for(int a=2; a<MX; a++){
        if(ps[a] > 0) continue;
        for(int b=a * 2; b < MX; b += a){
            ps[b] = a;
        }
    }
}

string solve(){
    map<int,int> mp;
    int g = A[0];
    for(int i=1; i<N; i++){
        g = gcd(g, A[i]);
    }
    if(g > 1) return "not coprime";
    for(int i=0; i<N; i++){
        int a = A[i];
        vector<int> cs = decompose(a);
        for(int c : cs){
            mp[c]++;
            if(mp[c] > 1){
                return "setwise coprime";
            }
        }
    }

    return "pairwise coprime";
}

int main(){
    init();
   // freopen("in.txt", "r", stdin);
    cin>>N;
    for(int i=0; i<N; i++){
        cin>>A[i];
    }

    cout<<solve()<<endl;


    return 0;
}

Measured memory_bytes: 11524
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T, typename S> T expo(T b, S e, const T &m){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b)%m, e>>1, m): (b*expo((b*b)%m, e>>1, m))%m;}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 3e3 + 3;
bool win[MAXN];
vector<int> adj[MAXN];
int arr[MAXN];
int n;

void dfs(int r, int p) {
  bool leaf = true;
  win[r] = false;
  for(auto &elem: adj[r]) {
    if(elem != p) {
      dfs(elem, r);
      if(arr[r] > arr[elem] and !win[elem]) {
        win[r] = true;
      }
      leaf = false;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  int a, b;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for(int i = 1; i < n; i++) {
    cin >> a >> b;
    adj[a].push_back(b), adj[b].push_back(a);
  }
  vector<int> ans;
  for(int i = 1; i <= n; i++) {
    memset(win, false, sizeof win);
    dfs(i, 0);
    if(win[i]) {
      ans.push_back(i);
    }
  }
  for(auto &elem: ans) {
    cout << elem << ' ';
  }
  cout << endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int c = int(n/2);
    double ans = double(c)/n;
    cout << fixed;
    cout << std::setprecision(10) << (1 - ans)  << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[100005];
int gcd(int x,int y){
    return y==0?x:gcd(y,x%y);
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]>k)
            a[i]-=k;
        else
            a[i]=k-a[i];
    }
    int tmp = a[1];
    for(int i=2;i<=n;i++){
        tmp=gcd(tmp,a[i]);
    }
    cout<<tmp;
}



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

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> num(N);
	//vector<set<int>> sum(N);
	vector<array<int, 2>> raw(M);
	for (int i = 0; i < M; i++) {
		cin >> raw[i][0] >> raw[i][1];
		num[raw[i][0]-1].push_back(raw[i][1]);
	}
	for (int i = 0; i < N; i++) {
		sort(num[i].begin(), num[i].end());
		//sum[i].insert(num[i].begin(), num[i].end());
	}
	for (int i = 0; i < M; i++) {
		//auto it = sum[raw[i][0]-1].find(raw[i][1]);
		auto it = lower_bound(num[raw[i][0] - 1].begin(), num[raw[i][0] - 1].end(), raw[i][1]);
		if (it != num[raw[i][0]-1].end()) {
			printf("%06d%06d\n", raw[i][0], distance(num[raw[i][0]-1].begin(), it) + 1);
		}
		else {
			cerr << "ERROR" << endl;
		}
	}
}



Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>
 
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	vector<int>c(9, 0);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (399 >= a[i]) {
			c[0]++;
		} else if (799 >= a[i]) {
			c[1]++;
		} else if (1199 >= a[i]) {
			c[2]++;
		} else if (1599 >= a[i]) {
			c[3]++;
		} else if (1999 >= a[i]) {
			c[4]++;
		} else if (2399 >= a[i]) {
			c[5]++;
		} else if (2799 >= a[i]) {
			c[6]++;
		} else if (3199 >= a[i]) {
			c[7]++;
		} else {
			c[8]++;
		}
	}
 
	int min = 0, max = 0;
 
	for (int i = 0; i < 8; i++) {
		if (c[i] > 0) {
			min++;
		}
	}
	if (min == 0) {
		min++;
		c[8]--;
	}
	max += min + c[8];
 
	cout << min << " " << max << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int h1 = scan.nextInt();
		int m1 = scan.nextInt();
		int h2 = scan.nextInt();
		int m2 = scan.nextInt();
		int k = scan.nextInt();
		int di = (h2*60+m2 - (h1*60+m1));
		System.out.print(di - k);

	}
}

Measured memory_bytes: 35576
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int x,d, k;
   cin>>x>>k>>d;
   x=abs(x);
   long long int steps=k-min(k, x/d);
       x-=(min(k, (x/d))*d);
       k=steps;
       if(k%2==0) cout<<abs(x)<<endl;
       else cout<<abs(x-d)<<endl;
} 


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, K, sum=0;
	
	cin >> N >> K;
	
	int l[N];
	
	for(int i=0; i<N; i++)
		cin >> l[i];
	
	sort(l, l+N, greater<int>());
	
	for(int i=0; i<K; i++){
		sum += l[i];
	}
	
	cout << sum;
	
	return 0;
}

Measured memory_bytes: 256
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
#define ui unsigned int
#define rui register ui
#define inl inline
#define rep(i,l,r) for(rui i=l,_=r;i<_;i++)
#define mxn 12
ui n,m,x,p[mxn];
bool f[1<<mxn],b[mxn][mxn];
char a[mxn][mxn];
inl ui rnd() {
	x^=x<<13;
	x^=x>>17;
	x^=x<<5;
	return x;
}
inl void rsh() {
	rep(i,1,n)
		swap(p[i],p[rnd()%i]);
}
int main() {
	srand(time(0));
	x=rand();
	scanf("%d%d",&n,&m);
	rep(i,0,n)	p[i]=i;
	rep(i,0,n)	scanf("%s",a[i]);
	ui y=CLOCKS_PER_SEC*15;
	while(clock()<<3<=y) {
		rsh();
		memset(b,1,sizeof(b));
		rep(i,0,m)	rep(j,i,m)	rep(k,0,n)
			if(a[p[k]][i]!=a[p[n-k-1]][j])
				b[i][j]=0;
		memset(f,0,sizeof(f));
		f[0]=1;
		rep(k,0,1<<m)	if(f[k])
			rep(i,0,m)	rep(j,i+1,m)
				if(!(1<<i&k)&&!(1<<j&k)&&b[i][j])
					f[k|(1<<i)|(1<<j)]=1;
		bool chk=0;
		if(!(m&1))
			chk=f[(1<<m)-1];
		else	rep(i,0,m)
			chk|=f[(1<<m)-1-(1<<i)];
		if(chk) {
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int count(int);
int main(void){
    int n,x;
    while(1){
        cin >> n;
        if(n==0) break;
 
        x=count(n)/10;
        cout << x/365+1 << endl;
    }
}
 
int count(int n){
    if(n==1) return 1;
    else if(n==2) return 2;
    else if(n==3) return 4;
    else return count(n-1)+count(n-2)+count(n-3);
}


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

int main(void){
    int N,L;
    cin>>N>>L;
    
    vector<int> a(N,0);
    vector<int> c(N,0);
    for(int i=0;i<N;i++){
        a[i]=abs(L+i);
        c[i]=L+i;
    }

    int count=300;
    int b;
    for(int j=0;j<N;j++){
       if(a[j]<=count){
           count=a[j];
           b=j;
       }
    }

    int ans=0;
    for(int k=0;k<N;k++){
        if(k!=b){
        ans+=c[k];
        }
    }

    cout<<ans<<endl;






    return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    for(ll i=0;i<a;i++)cin >> p[i];
    for(ll i=0;i<b;i++)cin >> q[i];
    for(ll i=0;i<c;i++)cin >> r[i];

    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());

    sort(q.begin(),q.end());
    reverse(q.begin(),q.end());
    
    for(ll i=0;i<x;i++)r.push_back(p[i]);
    for(ll i=0;i<y;i++)r.push_back(q[i]);
    
    sort(r.begin(),r.end());
    reverse(r.begin(),r.end());

    ll s=0;
    for(ll i=0;i<x+y;i++)s+=r[i];

    //for(ll i=0;i<r.size();i++)cout << r[i] << endl;

    cout << s << endl;

}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a > b) {
      cout << "a > b" << endl;
  } else if (a == b) {
      cout << "a == b" << endl;
  } else if (a < b) {
      cout << "a < b" << endl;
  } else {
      cout << "error" << endl;
  }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define int long long
#define md 1000000007
using namespace std;
int h,w;
int a[100][100],b[100][100];
int dp[81][81][13000];
int path(int i,int j,int k){
	if(dp[i][j][k]!=-1)
		return dp[i][j][k];
	int sum=LONG_LONG_MAX;
	int nk[2]={abs(k+a[i][j]-b[i][j]),abs(k-a[i][j]+b[i][j])};
	if(i==h-1 and j==w-1)
		return min(nk[0],nk[1]);

	if(i<h-1)
		sum=min(path(i+1,j,nk[0]),min(path(i+1,j,nk[1]),sum));
	if(j<w-1)
		sum=min(path(i,j+1,nk[0]),min(path(i,j+1,nk[1]),sum));
	return dp[i][j][k]=sum;
}
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cin >> h >> w;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin >> a[i][j];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin >> b[i][j];
	memset(dp,-1,sizeof(long long)*81*81*13000);
	cout << path(0,0,0) << endl;
}


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

void fast_io(){ios_base::sync_with_stdio(false); cin.tie(NULL);}
void test_here(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);}

bool is_safe(ll i, ll j, vector<vector<char> >&grid, ll r, ll c)
{
	if(i==r||j==c) return false;
	if(grid[i][j]!='.') return false;
	return true;
}

ll no_of_paths(vector<vector<char> >& grid, ll r, ll c, vector<vector<ll> >&dp, ll i=0, ll j=0)
{
	if(i==r-1 && j==c-1) return 1;

	if(dp[i][j]!=-1) return dp[i][j];

	ll ans=0;
	if(is_safe(i+1,j, grid,r,c)) ans += no_of_paths(grid,r,c,dp, i+1,j); ans=ans%M;
	if(is_safe(i,j+1, grid,r,c)) ans += no_of_paths(grid,r,c,dp, i,j+1);

	return dp[i][j]= ans%M;
}

void qH()
{
	ll h,w; cin>>h>>w;
	vector<vector<char> > grid(h+1, vector<char>(w+1));

	for(ll i=0;i<h;i++)
		for(ll j=0;j<w;j++) cin>>grid[i][j];

	vector< vector<ll> > dp(h+1, vector<ll>(w+1,-1));
	
	cout<<no_of_paths(grid,h,w,dp,0,0);
}


int main()
{
	//test_here();
	qH();
}

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

int dfs(ll n, int max_num, int mask){
    if (n > max_num)
        return 0;

    int a = dfs(10 * n + 3, max_num, mask | 1);
    int b = dfs(10 * n + 5, max_num, mask | 2);
    int c = dfs(10 * n + 7, max_num, mask | 4);

    if (mask == 7) {
        return a + b + c + 1;
    } else {
        return a + b + c;
    }
}

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

    cout << dfs(0, n, 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;

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

	string s;
	cin >> s;

	if (s[0] == s[1]) {
		cout << 1 << " " << 2 << "\n";
		return 0;
	}
	else {
		REP(i, 2, s.length()) {
			if (s[i - 1] == s[i]) {
				cout << i << " " << i + 1 << "\n";
				return 0;
			}
			else if (s[i - 2] == s[i]) {
				cout << i - 1 << " " << i + 1 << "\n";
				return 0;
			}
		}
	}

	cout << -1 << " " << -1 << "\n";

	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;

//#define cerr if (false) cerr

int n;
vector<ll> v, av, bv;
multiset<ll> a, b;
ll x, y, anw = -1e18;

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);

  cin >> n;
  v.resize(n*3);
  av.resize(n*3);
  bv.resize(n*3);

  for (int i = 0; i < n*3; i++) cin >> v[i];

  for (int i = 0; i < 3*n; i++) {
    a.insert(v[i]);
    x += v[i];
    if (a.size() > n) {
      x -= *a.begin();
      a.erase(a.begin());
    }
    if (a.size() == n)
      av[i] = x;
    else
      av[i] = -1e18;
  }

  for (int i = 3*n-1; i >= 0; i--) {
    b.insert(-v[i]);
    y += v[i];
    if (b.size() > n) {
      y -= -*b.begin();
      b.erase(b.begin());
    }
    if (b.size() == n)
      bv[i] = y;
    else
      bv[i] = 1e18;
  }

  cerr << "av" << endl;
  for (auto x: av) cerr << x << ' '; cerr << endl;
  cerr << "bv" << endl;
  for (auto x: bv) cerr << x << ' '; cerr << endl;

  for (int i = 0; i < n*3-1; i++)
    anw = max(anw, av[i]-bv[i+1]);

  cout << anw << endl;
}

Measured memory_bytes: 18688
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  _ <- getLine                                                                                                                                        
  as <- map read . words <$> getLine :: IO [Integer]                                                                                                  
  let (c,a,b) = solve as 0 0 1000000000                                                                                                               
  print $ if even c then a else a - 2 * b                                                                                                             
                                                                                                                                                      
solve :: [Integer] -> Int -> Integer -> Integer -> (Int,Integer,Integer)                                                                              
solve [] c a b = (c,a,b)                                                                                                                              
solve (x:xs) c a b                                                                                                                                    
  | x >= 0 && x < b = solve xs c (a + x) x                                                                                                            
  | x >= 0 && x >= b = solve xs c (a + x) b                                                                                                           
  | x < 0 && (-x) < b = solve xs (c + 1) (a - x) (-x)                                                                                                 
  | x < 0 && (-x) >= b = solve xs (c + 1) (a - x) b

Measured memory_bytes: 40188
#include <stdio.h>
 
char S[101010];
 
int main()
{
	scanf("%s", S);
 
	int app[26];
	for (int i = 0; i < 26; ++i) {
		app[i] = 0;
	}
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = 1;
	}
	for (int i = 0; i < 26; ++i) {
		if (app[i]==0) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	puts("None");
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>

int main() {
  int N, T, A;
  std::cin >> N >> T >> A;
  double H[N], Adash = 0.0, temp, ans;
  for (int i = 0; i < N; i++) {
    std::cin >> H[i];
    temp = T - (H[i] * 0.006);
    if (i == 0 || std::abs(temp - A) < std::abs(Adash - A)) {
      Adash = temp;
      ans = i;
    }
  }

  std::cout << ans + 1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    k = int(input())
    xs = list(map(int, input().split()))
    ans = 0
    for x in xs:
        ax = x
        bx = k - x
        ans += min(ax*2, bx*2)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

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

int main() {
    ll N;
    cin >> N;
    vector<ll> H(N);
    rep(i,N){
        cin >> H[i];
    }

    ll count = 0,maxCount=0;
    rep(i,N-1){
        if(H[i] >= H[i+1]){
            count++;
            maxCount = max(maxCount,count);
        }else{
            count = 0;
        }
    }

    cout << maxCount << endl;
}


Measured memory_bytes: 4052