akhauriyash/Code-Regression huggingface dataset:
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
map<pair<ll,ll> , ll >  mp;
ll func(ll X,ll S){
    if(X < 0) return 0;
    if(S < 0) return 0;
    if(X == 0 && S == 0) return 1;
    if(mp.find(make_pair(X,S)) != mp.end() ){
        return mp[make_pair(X,S)];
    }
    ll ret = 0;
    ret = func(X/2,S/2);
    ret %= MOD;
    if(X >= 1 && S >= 1) ret += func((X-1)/2,(S-1)/2);
    ret %= MOD;
    if(S >= 2) ret += func(X/2,(S-2)/2);
    ret %= MOD;
    mp[make_pair(X,S)] = ret;
    return ret;
}

int main() {
    ll N;
    cin >> N;
    cout << func(N,N) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;
ll N;
int ans = 0;
void dfs(ll x,int a,int b,int c){
	if(x>N) return;
	if(a&b&c)ans++;
	dfs(10*x+3,1,b,c);
	dfs(10*x+5,a,1,c);
	dfs(10*x+7,a,b,1);
}
int main() {;
	cin>>N;
	dfs(0,0,0,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
//Name: Ring
//Level: 1
//Category: 文字列，やるだけ
//Note:

/*
 * 指輪は必ず10文字，探す文字列は高々10文字なので指輪の文字列を2つくっつけると
 * 探す文字列が取れるなら必ず出現する．
 */
#include <iostream>
#include <string>

using namespace std;

int main() {
    string need;
    cin >> need;
    int N;
    cin >> N;
    int ans = 0;
    while(N--) {
        string str;
        cin >> str;
        str += str;
        if(str.find(need) != string::npos) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 0
/*
  "I knew I shouldn't have
   gotten out of bed today."
   - Squidward Tentacles
*/
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<numeric>

#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<unordered_map>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#include<iomanip>
#include<fstream>
#include<chrono>
using namespace std;
using namespace __gnu_pbds;

#define int          long long
#define pii          pair<int,int>
#define vi           vector<int>
#define peque        priority_queue
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define all(x)       x.begin(),x.end()
#define ball(x)      x.rbegin(),x.rend()
#define mem(x,y)     memset(x,y,sizeof(x))
#define oset         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define VR46         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MOD = (1e+9)+7;

int modexp(int base, int exp)
{
    int res = 1;
    while( exp>0 )
    {
        if( exp&(int)1 ) res *= base, res %= MOD;
        base *= base, base %= MOD, exp >>= (int)1;
    }
    return res;
}

int modinv(int a)
{
    return modexp( a,MOD-2 );
}

int fac[1000005];

int ferm(int n, int k) 
{
   if (k==0) return 1; 
  
    return (fac[n]* modinv(fac[k]) % MOD * modinv(fac[n-k]) % MOD) % MOD; 
} 

signed main()
{
    VR46 ofstream out("output.txt");
    // auto start = chrono::high_resolution_clock::now();

    // GANDU THODE TEST CASE BNAKE TEST KRLE
    int t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        fac[0] = 1;
        rep(i,1,1000000)
        fac[i] = (fac[i-1]*i)%MOD;

        int x, y;
        cin>>x>>y;
        if( (x+y)%3 != 0 ) return cout<<"0\n", 0;

        int n = (x+y)/3;
        int xx = n, yy = 2*n;
        bool f = false;
        int idx = 0;
        while( xx<=2*n )
        {
            if( xx==x && yy==y )
            {
                f = true;
                break;
            }
            xx++, yy--, idx++;
        }
        if( !f ) return cout<<"0\n", 0;

        cout<< ferm( n,idx )%MOD <<"\n";
    }

    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout<<"Time taken by function: "<<duration.count()<<" milliseconds"<<endl;
}

Measured memory_bytes: 8064
from collections import defaultdict as dd
from itertools import permutations as p

def factorize(n):
    d = dd(int)
    for i in range(2, int(n**0.5)+1):
        while n%i==0:
            d[i] += 1
            n //= i
        if not n:
            break
    if n>1:
        d[n] += 1
    return d

N = int(input())
d = dd(int)
for i in range(1, N+1):
    e = factorize(i)
    for i,j in e.items():
        d[i] += j

ans = 0
for i, j, k in p(d.values(), 3):    
    if i>=2 and j>=4 and k>=4:
        ans += 1
ans //= 2

for i, j in p(d.values(), 2):
    if i>=2 and j>=24:
        ans += 1
    if i>=4 and j>=14:
        ans += 1

for i in d.values():
    if i>=74:
        ans += 1

print(ans)

Measured memory_bytes: 3316
//const int N = 105;
//ll dp[3*N][N];
//ll _(){
//    ll n,w;
//    cin >> n >> w;
//    vpll arr(n);
//    cin >> arr;
//    ll w0 = arr[0].X;
//    for(auto _ : arr){
//        for(int i = 3*n; i >= 0; --i)
//            for(int j = n-1; j >= 0; --j){
//                ll cw = w0*i+j+_.X;
//                ll ni = cw/w0;
//                ll nj = cw%w0;
//                dp[ni][nj] = max(dp[ni][nj],dp[i][j]+_.Y);
//            }
//    }
//    ll ans = 0;
//    for(int i = 3*n; i >= 0; --i)
//        for(int j = n-1; j >= 0; --j)
//            if(i*w0+j <= w)
//                ans = max(ans,dp[i][j]);
//    return ans;
//
//}
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define X first
#define Y second
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
template <typename F, typename S> static
istream& operator>>(istream& stream, pair<F, S>& t){
    return stream >> t.first >> t.second;
}
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
const int N = 105;
ll dp[3*N][N];
ll _(){
    ll n,w;
    cin >> n >> w;
    vpll arr(n);
    cin >> arr;
    ll w0 = arr[0].X;
    for(auto _ : arr){
        for(int i = 3*n; i >= 0; --i)
            for(int j = n-1; j >= 0; --j){
                ll cw = w0*i+j+_.X;
                ll ni = cw/w0;
                ll nj = cw%w0;
                dp[ni][nj] = max(dp[ni][nj],dp[i][j]+_.Y);
            }
    }
    ll ans = 0;
    for(int i = 3*n; i >= 0; --i)
        for(int j = n-1; j >= 0; --j)
            if(i*w0+j <= w)
                ans = max(ans,dp[i][j]);
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//1-indexed
#include<vector>
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0):n(n_),bit(n_+1){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
	int lower_bound(T k)//k<=sum(ret)
	{
		if(k<=0)return 0;
		int ret=0,i=1;
		while((i<<1)<=n)i<<=1;
		for(;i;i>>=1)
			if(ret+i<=n&&bit[ret+i]<k)k-=bit[ret+=i];
		return ret+1;
	}
};
int N;
int X[2<<17],Y[2<<17];
pair<int,int>xy[2<<17];
long ans,mod=998244353,F[2<<17];
main()
{
	cin>>N;
	F[0]=1;
	for(int i=1;i<=N;i++)F[i]=F[i-1]*2%mod;
	for(int i=0;i<N;i++)
	{
		cin>>X[i]>>Y[i];
		xy[i]=make_pair(X[i],Y[i]);
	}
	sort(X,X+N);
	sort(Y,Y+N);
	BIT<int>up(N),down(N);
	for(int i=0;i<N;i++)
	{
		xy[i].first=lower_bound(X,X+N,xy[i].first)-X+1;
		xy[i].second=lower_bound(Y,Y+N,xy[i].second)-Y+1;
		down.add(xy[i].second,1);
	}
	sort(xy,xy+N);
	long ans=0;
	for(int i=0;i<N;i++)
	{
		down.add(xy[i].second,-1);
		int a=up.sum(xy[i].second);
		int b=i-a;
		int c=down.sum(xy[i].second);
		int d=(N-i-1)-c;
		long aX=(F[a]+F[d]+mod-1)%mod;
		long aY=(F[b]+F[c]+mod-1)%mod;
		(ans+=F[N]-aX*aY%mod+mod)%=mod;
		up.add(xy[i].second,1);
	}
	cout<<ans<<endl;
}


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

int main() {
  string s1,s2;
  cin >> s1 >> s2;

  reverse(s1.begin(),s1.end());
  if (s1==s2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int d;
//inputの時にresize
vector<int> c(26);
vector<vector<int>> s;
vector<int> t;
vector<int> p;
//last&next
vector<P> ln;
void input(){
    cin>>d;    
    s.resize(d,vector<int>(26));
    t.resize(d);
    p.resize(d);
    ln.resize(d,P(0,0));
    for(int i=0;i<26;i++)cin>>c[i];
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
}
void output(){
    for(int i=0;i<d;i++){
        cout<<t[i]<<endl;
    }
}
//aは全体の日程
void calc_p(vector<int> a){
    for(int i=0;i<d;i++){
        if(i==0)p[i]=0;
        else p[i]=p[i-1];
        p[i]+=s[i][a[i]];
        for(int j=0;j<26;j++){
            int last=-1;
            for(int k=i;k>=0;k--){
                if(a[k]==j){
                    last=k;
                    break;
                }
            }
            p[i]-=c[j]*(i-last);
        }
    }
}
int main(){
    input();
    for(int i=0;i<d;i++){
        cin>>t[i];
        t[i]--;
    }
    calc_p(t);
    for(int i=0;i<d;i++){
        cout<<p[i]<<endl;
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#include <limits.h>
#define maxn 10000000
#define pi acos(-1)
using namespace std;
double aabs(double x)
{
	if(x<0)return -x;
	return x;
}
int gcd(int a,int b)
{
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main()
{
	int n,ans=0;
	int a[107];
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			int t;
			if(a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
				ans++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(i!=n)cout<<a[i]<<" ";
		else cout<<a[i]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3088
x,ar=int(input())-1,[]
if(x==0): ar.append('a')
else:
    while(x>0):
        ar.append(chr(97+x%26))
        x//=26
        x=x-1
        if(x==0): ar.append('a')
ar.reverse()
ans=''.join(ar)
print(ans)

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

int main(){
  char s[6];
  for(int i = 0;i<6;i++){
    cin >> s[i];
  }
  if(s[2]==s[3]&&s[4]==s[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int cnt = 0;
    int max = 0;
    for (int i = 0; i < S.length(); i++) {
      if (S.charAt(i) == 'A' || S.charAt(i) == 'C' || S.charAt(i) == 'G' || S.charAt(i) == 'T') {
        cnt++;
      } else {
        max = Math.max(max, cnt);
        cnt = 0;
      }
    }
    if (max < cnt)
      max = cnt;
    System.out.println(max);
  }
}


Measured memory_bytes: 23636
L = input()
MOD = 10 ** 9 + 7

dp = [[0, 0] for i in range(len(L) + 1)]
dp[0][0] = 1

for i, b in enumerate(L):
    dp[i + 1][1] += 3 * dp[i][1]
    dp[i + 1][1] %= MOD

    if b == '1':
        dp[i + 1][0] += 2 * dp[i][0]
        dp[i + 1][0] %= MOD

        dp[i + 1][1] += dp[i][0]
        dp[i + 1][1] %= MOD

    else:
        dp[i + 1][0] += dp[i][0]
        dp[i + 1][0] %= MOD

print(sum(dp[-1]) % MOD)


Measured memory_bytes: 19700
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t H,W;cin>>H>>W;
  vector<vector<char>>A(H,vector<char>(W));
  for(int i=0;i<H;i++){
    string s;cin>>s;
    for(int j=0;j<W;j++)
      A[i][j]=s.at(j);
  }
  int64_t ans=0;
  for(int64_t k=0;k<W-1;k++){
  vector<vector<int64_t>>num(H,vector<int64_t>(H));
    for(int i=0;i<H;i++){
    int64_t sum=0;
      for(int j=0;j+i<H;j++){
      if(A[j][k]==A[i+j][k+1])
          sum++;
               num[j][i+j]=sum;          
      }}for(int i=0;i<H;i++){
    int64_t sum=0;
      for(int j=0;j+i<H;j++){
      if(A[i+j][k]==A[j][k+1])
          sum++;
               num[i+j][j]=sum;          
      }}vector<vector<int64_t>>dp(H+1,vector<int64_t>(H+1,0));
            for(int i=1;i<=H;i++)
             for(int j=1;j<=H;j++){
             dp[i][j]=min(dp[i-1][j],dp[i][j-1])+num[i-1][j-1];
             
             }ans+=dp[H][H];
      }cout<<ans<<endl;
        return 0;
}

Measured memory_bytes: 4828
#include <stdio.h>

int main(void) {
	int n;
	int a[105],count=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}

	for(int i=1;i<n;i++){
		if(a[i-1]==a[i]){
			a[i]=0;
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
int n;
string s;
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>s;
int cnt=0;
rep(i,0,1000)
{
	int c[3]={i/100,(i/10)%10,i%10};
	int f=0;
	rep(j,0,n)
	{
		if(s[j]==('0'+c[f]))
		f++;
		if(f==3)
		break;
	}
	if(f==3)
	cnt++;
}

cout<<cnt;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
 
using Graph = vector<vector<int>>;
 
// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}
 
int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;
 
    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; 
        dfs(G, v); 
        ++count;
    }
    cout << count-1 << endl;
}

Measured memory_bytes: 9596
from fractions import Fraction
import math

N = int(input())


taka = [0] * N
aoki = [0] * N

for i in range(N):
    t,a = map(int, input().split())
    if i == 0:
        taka[i] = t
        aoki[i] = a
    else:
        tmp = math.ceil(max(Fraction(taka[i-1], t), Fraction(aoki[i-1],a)))
        taka[i] = tmp*t
        aoki[i] = tmp*a

print(taka[-1] + aoki[-1])

Measured memory_bytes: 5176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
// 素因数分解
vector<pair<long long, long long>> prime_factorize(long long n)
{
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; ++p)
  {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0)
    {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}
int main()
{
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++)
  {
    if (i % k == 0)
    {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

ll mas[205], gauss[65];

int main()
{
 	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
 	ios_base::sync_with_stdio(0); cin.tie(0);
 	int test;
 	cin >> test;
 	for (int rep = 1; rep <= test; rep++)
 	{
 	 	int n;
 	 	string s;
		cin >> n;
		for (int i = 1; i <= n; i++) cin >> mas[i];
		cin >> s;
		
		for (int i = 0; i < 60; i++) gauss[i] = 0;

		int answer = 0;
		for (int i = n; i >= 1; i--)
		{
		 	ll cop = mas[i];
		 	bool fl = false;

		 	for (int bit = 59; bit >= 0; bit--)
		 		if (((cop >> bit) & 1) != 0)
		 		{
		 		 	if (gauss[bit] != 0) cop ^= gauss[bit];
		 		 	else
		 		 	{
		 		 	 	gauss[bit] = cop;
		 		 	 	fl = true;
		 		 	 	break;
		 		 	}
		 		}
		   	if (fl && s[i - 1] == '1') answer = 1;
		}
		cout << answer << '\n';
 	}
 	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main() {
  char c;
  string str = "aiueo";
  int aws = 0;
  cin >> c;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) != c) {
      aws++;
    }
  }
  if (aws != str.size()) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
using namespace std;
int cnt[500];
int main(){
	string a;
	cin>>a;
	if(a.size()==2)
		if(a[0]==a[1]){
			cout<<"1 2"<<endl;
			return 0;
		}
	if(a.size()>2){
		cnt[a[0]]++;
		cnt[a[1]]++;
		cnt[a[2]]++;
		if(cnt[a[0]]>1||cnt[a[1]]>1||cnt[a[2]]>1){
			cout<<"1 3"<<endl;
			return 0;
		}
		for(int i=3;i<a.size();++i){
			cnt[a[i-3]]--;
			cnt[a[i]]++;
			if(cnt[a[i]]>1){
				cout<<i-2+1<<" "<<i+1<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1"<<endl;
}

Measured memory_bytes: 512
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      Date now = new Date(next());
      Date check = new Date("2019/04/30");
      myout((now.getTime() <= check.getTime()) ? "Heisei" : "TBD");
	}
	//Method addition frame start



	//Method addition frame end
}


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

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

int main(){
  int N, M;
  cin >> N >> M;
  if(N==M) cout << "Yes";
  else cout << "No";
}


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

void pop (vector<int> &S, int &second, int &first) {
  second =  S[S.size() - 1];
  S.pop_back();
  first = S[S.size() - 1];
  S.pop_back();
}

int main() {
  vector<int> S;
  while (true) {
    string tmp;
    cin >> tmp;
    int second, first;
	  if(tmp == "*") {  // switch文書こうと思ったらstringじゃ使えなかった
      pop(S, second, first);
      S.push_back(first * second);
    } else if (tmp == "+") {
      pop(S, second, first);
      S.push_back(first + second);
    } else if (tmp == "-") {
      pop(S, second, first);
      S.push_back(first - second);
    } else if (tmp == "/") {
      pop(S, second, first);
      S.push_back(first / second);
    } else if (tmp == "") {
      goto BREAK_LABEL;
    } else {
      // 数値の場合はスタックする
      int i = stoi(tmp);
      S.push_back(i);
    }
  }
  BREAK_LABEL:
  cout << S[0] << endl;
}



Measured memory_bytes: 3216
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>

using namespace std;

struct edge{int u,v; double cost;};

bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
  }

edge *es;

int rak[10001],par[10001];
int x[10001],y[10001];

void init(int n){
  for(int i=1; i<=n; i++){
    par[i]=i;
    }
  }

int find(int x){
  if(par[x]==x){
    return x;
    }else{
    return par[x]=find(par[x]);
    }
  }

void unite(int x,int y){
   x=find(x);
   y=find(y);
   if(x==y) return;

   if(rak[x]<rak[y]){
     par[x]=y;
     }else{
     par[y]=x;
     if(rak[x]==rak[y]) rak[x]++;
     }
  }

bool same(int x,int y){
  return find(x)==find(y);
  }

double kruskal(int n,int r){
  sort(es,es+r,comp);
  init(n);
  double res=0;
  for(int i=0; i<r; i++){
    edge e = es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
        res+=e.cost;
      }
    }
    return res;
  }

int main(){

   int N,M;
   cin>>N>>M;

   es=new edge[M];

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

     cin>>x[i]>>y[i];

     }

   double mx=0;

   for(int i=0; i<M; i++){

     int a,b; cin>>a>>b;

     int p = (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]);
     double c = sqrt(p);

     edge e1={a,b,-c}; es[i]=e1;

     mx+=c;

     }

     printf("%.8f\n",mx+kruskal(N,M));

}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
    ll m=pow(10,18);
    ll n;
    cin >> n;
    ll a[n],i,f=1;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        if(a[i]==0)
            f=0;
    }
    if(f==0)
    {
        cout << "0" << endl;
        return 0;
    }
    ll s=1;
    for(i=0;i<n;i++)
    {
    if(s*a[i] > m || s*a[i] < s)
    {
        cout << "-1" << endl;
        return 0;
    }
    s=s*a[i];
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 4416
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;

int main(){
    int a[5];
    for(int i=0; i<5; i++){
        cin >> a[i];
    }
    int minmod=10;
    int ai=0;
    for(int i=0; i<5; i++){
        if(a[i]%10<minmod && a[i]%10!=0){
            minmod = a[i]%10;
            ai=i;
        }

    }
    int ans=0;
    for(int i=0; i<5; i++){
        if(ai==i){
            ans+=a[i];
        }else{
            if(a[i]%10){
                ans+=a[i]-(a[i]%10)+10;
            }else{
                ans+=a[i];
            }
        }
    }
    cout << ans << endl;
}

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

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int s = int.Parse(ReadLine());
            WriteLine(s >= 30?"Yes":"No");
        }
    }
}


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

 int main(){
    int N;
    vector<int> V, C;
    cin >> N;
    V.resize(N);
    for(int i=0; i<N; i++){
        cin >> V[i];
    }
    C.resize(N);
    for(int i=0; i<N; i++){
        cin >> C[i];
    }
    
    int _max = 0;
    for(int i=0; i<N; i++){
        _max += std::max(V[i] - C[i], 0);
    }

    cout << _max << endl;
    return 0;
 }

Measured memory_bytes: 256
N,Y=$<.read.split.map(&:to_i)

0.upto(N) do |a|
    0.upto(N-a) do |b|
        c = N-a-b
        if a*10000+b*5000+c*1000 == Y
            puts [a,b,c].join(' ')
            exit 0
        end
    end
end

puts '-1 -1 -1'

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define mp make_pair
int n,q;
struct edge{
	int v,c,w;
	edge(int vv,int cc,int ww){
		v=vv;
		c=cc;
		w=ww;
	}
};
vector<edge> G[123456];
int cnt[123456],in[123456],out[123456],tim=0;
int pa[18][123456];
bool anc(int x,int y){
	return in[x]<=in[y] && out[x]>=out[y];
}
void dfs(int cur,int pre){
	in[cur]=++tim;
	pa[0][cur]=pre;
	for(edge tmp:G[cur]){
		int nxt=tmp.v,col=tmp.c,w=tmp.w;
		if(nxt==pre) continue;
		dfs(nxt,cur);
	}
	out[cur]=++tim;
}
void build(){
	for(int i=1;i<18;i++)
		for(int j=1;j<=n;j++)
			pa[i][j]=pa[i-1][pa[i-1][j]];
}
int lca(int x,int y){
	if(anc(x,y)) return x;
	if(anc(y,x)) return y;
	for(int i=17;i>=0;i--)
		if(!anc(pa[i][x],y)) x=pa[i][x];
	return pa[0][x];
}
int ans[123456],q_col[123456],q_val[123456],dist[123456];
vector<int> query[123456];
void solve(int cur,int pre,int cur_dis){
	for(int id:query[cur]){
		int mul=1;
		if(id<0) mul=-2,id=-id;
		ans[id]+=mul*(cur_dis+cnt[q_col[id]]*q_val[id]-dist[q_col[id]]);
	}
 
	for(edge tmp:G[cur]){
		int nxt=tmp.v,col=tmp.c,w=tmp.w;
		if(nxt==pre) continue;
		cnt[col]++;
		dist[col]+=w;
		solve(nxt,cur,cur_dis+w);
		dist[col]-=w;
		cnt[col]--;
	}
}
int32_t main(){
	ios::sync_with_stdio();
	cin.tie(0);
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int u,v,c,w;cin>>u>>v>>c>>w;
		G[u].push_back(edge(v,c,w));
		G[v].push_back(edge(u,c,w));
	}
	dfs(1,1);
	build();
	for(int i=1;i<=q;i++){
		int u,v;cin>>q_col[i]>>q_val[i]>>u>>v;
		query[u].push_back(i);
		query[v].push_back(i);
		query[lca(u,v)].push_back(-i);
	}
	solve(1,0,0);
 
	for(int i=1;i<=q;i++)
		cout<<ans[i]<<endl;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h+2, vector<char>(w+2, '.'));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> s[i][j];
        }
    }

    int flag = 0;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(s[i][j] == '#'){
                if(s[i-1][j] == '.' && s[i][j+1] == '.' &&
                s[i+1][j] == '.' && s[i][j-1] == '.'){
                    flag = 1;
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int LINF=1e18;
const int MOD=1e9+7;
//
int main(){
    int ans=700;
    string s; cin>>s;
    FOR(i,0,3){
        if(s[i]=='o') ans+=100;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 764
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int L = sc.nextInt();
    	String ans = "";
    	List<String> array = new ArrayList<String>();
    	
    	for (int i = 1;i <= N+1 ; i++){
    		String s = sc.nextLine();
    		array.add(s);
    	}
    	
    	Collections.sort(array);
    	
    	for (int i=1 ; i <=N ; i++){
    		ans += array.get(i);
    	}
    	
    	System.out.println(ans);
    	
    	
    	
    	
    }
}
   

Measured memory_bytes: 14020
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
#define fl(i,a,n) for(int i=a;i<=n;i++)
#define pb push_back
#define pob pop_back
#define int long long int
#define ff first
#define ss second
#define pi 3.1415926535898
#define vi vector<int>
#define mi map<int,int>
#define umi unordered_map<int,int>
#define endl "\n"
#define w(x) int x; cin>>x; while(x--)
#define db(x) cout<<(#x)<<" "<<(x)<<"\n";
#define db2(x,y) cout<<(#x)<<" "<<(x)<<" ,"<<(#y)<<" "<<(y)<<"\n";
#define db3(x,y,z) cout<<(#x)<<" "<<(x)<<" ,"<<(#y)<<" "<<(y)<<" ,"<<(#z)<<" "<<(z)<<"\n";
#define print(a) for(auto x:a){cout<<x<<" ";}
#define ios ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
//using namespace boost::multiprecision;
int mod = 1000000007;
int gcd(int a, int b) {
    return (b == 0) ? a : gcd(b, a % b);
}
int lcm(int a, int b) {
    return (a * b) / gcd(a, b);
}
template<class type>
type power(type x, int n) {
    type temp; int y = n;
    if (y == 0) return 1;
    temp = power(x, y / 2);
    return ((y % 2) ? ((y > 0) ? x * temp * temp : (temp * temp) / x) : temp * temp);
}
void c_p_c() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {

    ios
    //c_p_c();
    //w(t)
    {
        string s;
        cin>>s;
        if(s[2]==s[3] and s[4]==s[5]){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
    }

    return 0;
}
//ctrl+option+F to auto format- sublimeastyleformat package


Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


class Edge:
    def __init__(self,arg_to,arg_dist):
        self.to = arg_to
        self.dist = arg_dist

class Info:
    def __init__(self,arg_node_id,arg_sum_dist):
        self.node_id = arg_node_id
        self.sum_dist = arg_sum_dist

    def __lt__(self,another):
        return self.sum_dist < another.sum_dist


V = int(input())
G = [[] for _ in range(V)] #隣接グラフ
min_dist = [BIG_NUM]*V

for _ in range(V):
    node_id,num_adj,*tmp_array = list(map(int,input().split()))
    for i in range(0,len(tmp_array),2):
        G[node_id].append(Edge(tmp_array[i],tmp_array[i+1]))

min_dist[0] = 0
Q = []
heappush(Q, Info(0,0))

while len(Q) > 0:
    info = heappop(Q)
    if info.sum_dist > min_dist[info.node_id]:continue
    for e in G[info.node_id]:
        if min_dist[e.to] > info.sum_dist+e.dist:
            min_dist[e.to] = info.sum_dist+e.dist
            heappush(Q, Info(e.to,min_dist[e.to]))

for i in range(V):
    print("%d %d"%(i,min_dist[i]))



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

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans;
    ans = n / x * t;
    if(n%x!=0) ans += t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
newH=[1000*t-x*6 for x in H]
dif=float('inf')
ans=-1
for i in range(n):
    if abs(1000*a-newH[i])<dif:
        dif=abs(1000*a-newH[i])
        ans=i
print(ans+1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
struct node{
	int x,y;
}a[N],b[N]; 
int fun(int x)
{
	int cnt=0;
	while(x)
	{
		x/=10;
		cnt++;
	}
	return cnt;
}
int main()
{
	ll n;
	while(cin>>n)
	{
		ll ans=1e9;
		for(ll i=1;i*i<=n;i++)
		{
			if(n%i==0)
			{
				ll a=fun(i),b=fun(n/i);
				ans=min(ans,max(a,b));
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1 << 30;
const uint64_t MOD = 1000000000 + 7;

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

	vector<int> d(k);
	for (int i = 0; i < k; i++)
	{
		cin >> d.at(i);
	}

	for (int i = n; ; i++)
	{
		bool ok = true;
		for (int j = 0; j < k; j++)
		{
			if (to_string(i).find(to_string(d.at(j))) != string::npos)
			{
				ok = false;
				break;
			}
		}

		if (ok)
		{
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    string s; cin >> s;
    int cnt = 0;
    int ans = 0;
    rep(i,s.size()){
        if(s[i]=='A' || s[i]=='G' ||s[i]=='C' ||s[i]=='T'){
            cnt++;
            ans = max(cnt,ans);
        }else {
            cnt=0;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {
	
	int sum(int[] a, int[] b) {
		
		
		return 0;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0 ;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int[] sumForward = new int[n];
		sumForward[0] = arr[0];
		for(int i = 1;i<n;i++) {
			sumForward[i] = sumForward[i-1]+arr[i];
		}
		int[] sumBackward = new int[n];
		sumBackward[n-1] = arr[n-1];
		for(int i = n-2; i>=0;i--) {
			sumBackward[i] = sumBackward[i+1]+arr[i];
		}
		int min = Math.abs(sumForward[0] - sumBackward[1]);
		for(int i = 0 ;i<n-1;i++) {
			if(min>Math.abs(sumForward[i]-sumBackward[i+1])) {
				min = Math.abs(sumForward[i]-sumBackward[i+1]);
			}
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 22996
#include <stdio.h>
#include <stdlib.h>

#define TRUE 1
#define FALSE 0
#define MAX 397

int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int top=0,S[100];

int main(){
  int x,i,x1,x2,count=0;
  char s[MAX];
  
   for( i = 0 ; i < MAX ; i++ )
     {
      scanf("%c",&s[i]);
      if(s[i] ==  '\n' ) break;
      count++;
     }
  
  for(i = 0 ; i <= count ; i++)
    {
      if(s[i] == ' ' || s[i] == '\n') continue; 
      else if ( s[i] == '+' )
	{
	  x = pop() + pop();
	  if(x < -1000000000 || x  > 1000000000 ) return 0;
	  push(x);
	}
      else if ( s[i] == '-' )
	{
	  x1 = pop();
	  x2 = pop();
	  x = x2 - x1;
	  if(x < -1000000000 || x  > 1000000000 ) return 0;
	  push(x);
	}
      else if ( s[i] == '*' )
	{
	  x = pop() * pop();
	  if(x < -1000000000 || x  > 1000000000 ) return 0;
	  push(x);
	}
      else
	{
	  if(i == 0 || s[i-1] ==  ' ')
	    {
	      x = atoi(&s[i]);
	      if(x < 0 || x > 1000000) return 0;
	      push(x);
	    }
	}
    }
  
  for(i = 1 ; i <=  top ; i++ )
    {
      printf("%d",S[i]);
    }

  printf("\n");
  
  return 0;
}

int isEmpty()
{
  if(top == 0) return TRUE;
  else return FALSE;
}

int isFull()
{
  if(top >= MAX-1) return TRUE;
  else return FALSE;
}

void push(int x)
{
  if(isFull()) exit(2);
  top++;
  S[top] = x;
}

int pop()
{
  if(isEmpty()) exit(1);
  top--;
  return S[top+1];
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> dp(N + 1);
    vector<int> V(M);
    rep(i,0,M)cin >> V[i];
    rep(i,0,M){
        dp[V[i]] = -1;
    }
    dp[0] = 1;
    dp[1] = dp[1] == -1 ? 0 : dp[0];
    rep(i,2,N+1){
        if(dp[i] == -1)continue;
        dp[i] = max(dp[i-1], 0LL) + max(dp[i-2], 0LL);
        dp[i] %= MOD;
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main()
{
  int N;
  scanf("%d",&N);
  
  int L[N];
  int i,j,k,tmp,sum=0;
  for(i=0;i<N;i++){
    scanf("%d ",&L[i]);
  }
  
  for (i=0; i<N; ++i) {
    for (j=i+1; j<N; ++j) {
      if (L[i] < L[j]) {
        tmp =  L[i];
        L[i] = L[j];
        L[j] = tmp;
      }
    }
  }
  
  for(i=1;i<N;i++)
    sum+=L[i];
  
  if(sum >L[0])
    puts("Yes");
  
  else
    puts("No");

  return 0;
}

Measured memory_bytes: 128
# coding: utf-8
n = int(input())
for i in range(n):
    a,b,c = list(map(int,input().split()))
    if a*a == b*b + c*c or b*b == c*c + a*a or c*c == a*a + b*b:
        print("YES")
    else:
        print("NO")
    


Measured memory_bytes: 5604
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int n = nextInt();
		int k = nextInt();
		String[] wk = next().split("");
		wk[k - 1] = wk[k - 1].toLowerCase();

		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < wk.length; i++) {
			builder.append(wk[i]);
		}

		out.println(builder.toString());
	}

	private void solveB() {
		int n = nextInt();

		out.println("");
	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int u, v;
    long long int x = 0, y = 0;
    for(int i = 0; i<n-1; i++){
        cin >> u >> v;
        x = x + (long long int)min(u,v) * (n - max(u, v) + 1);
        y = y + (long long int)(i + 1) * (n - i);
    }
    cout << y + n - x;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            int mm = 0;
            int idx = 0;
            for (int j = 0; j < n; j++) {
                if ((mm > a[j] || mm == 0) && a[j] != 0) {
                    mm = a[j];
                    idx = j;
                }

            }
            if (mm == 0)
                break;

            ans += mm;

            int idl = 0;
            int idr = 0;
            for (int j = idx; j >= 0; j--) {
                if (a[j] == 0) {
                    idl = j;
                    break;
                }
                if (j == 0) {
                    idl = -1;
                    break;
                }
            }
            for (int j = idx; j < n; j++) {
                if (a[j] == 0) {
                    idr = j;
                    break;
                }
                if (j == n - 1) {
                    idr = n;
                    break;
                }
            }

            for (int j = idx; j < idr; j++) {
                a[j] -= mm;
            }
            for (int j = idx - 1; j > idl; j--) {
                a[j] -= mm;
            }

        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int H, W;
char route[110][110];
int main() {
    cin >> H >> W;
    vector<int> checkerH(H);
    vector<int> checkerW(W);

    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            cin >> route[i][j];
            if(route[i][j] == '#') {
                checkerH.at(i) = 1;
                checkerW.at(j) = 1;
            }
        }
    }

    for(int i = 0; i < H; ++i) {
        if(checkerH.at(i) == 1) {
            for(int j = 0; j < W; ++j) {
                if(checkerW.at(j) == 1) {
                    cout << route[i][j];
                }
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
		Scanner cin = new Scanner();
	  int[] pInts = new int[3];
    int[] jInts = new int[2];
	  for (int i = 0; i < 3; i++)
	  {
	    pInts[i] = cin.nextInt();
	  }
	  for (int i = 0; i < 2; i++)
	  {
	    jInts[i] = cin.nextInt();
	  }
    Console.WriteLine(pInts.Min(x => x) + jInts.Min(x => x) - 50);
		return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 5804
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll unko = 1;
	for (int i = 0; i < 9; i++) {
		unko *= 10;
	}
	ll x1 = 0, y1 = 0;
	ll x2 = unko, x3 = 1;
	ll y2, y3;
	ll s;
	cin >> s;
	y3 = (s - 1) / (ll)unko + 1;
	y2 = ((ll)unko - (s % (ll)unko)) % (ll)unko;
	for (int i = 0; i < 9; i++) {
		unko *= 10;
	}
	if (s == unko) {
		y3 = 1e9;
		y2 = 0;
	}
	printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);
}


Measured memory_bytes: 256