akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int sx, sy, tx, ty;

void solve(){
    cin >> sx >> sy >> tx >> ty;
    int xsa = tx - sx;
    int ysa = ty - sy;
    for(int i=0; i<xsa; i++){
        cout << 'R';
    }
    for(int i=0; i<ysa; i++){
        cout << 'U';
    }
    for(int i=0; i<xsa; i++){
        cout << 'L';
    }
    for(int i=0; i<ysa; i++){
        cout << 'D';
    }
    cout << 'D';
    for(int i=0; i<=xsa; i++){
        cout << 'R';
    }
    for(int i=0; i<=ysa; i++){
        cout << 'U';
    }
    cout << 'L' << 'U';
    for(int i=0; i<=xsa; i++){
        cout << 'L';
    }
    for(int i=0; i<=ysa; i++){
        cout << 'D';
    }
    cout << 'R' << endl;
    

}

int main(){
    solve();
}

Measured memory_bytes: 256
a, b = map(int, input().split())


def gcd(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return gcd(y, x % y)


def get_div(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if n != i * i:
                res.append(n//i)
    res.sort()
    return res


div = get_div(gcd(a, b))
kouho = []
for i in range(len(div)):
    if div[i] == 1:
        continue
    if len(kouho) == 0:
        kouho.append(div[i])
        continue
    for x in range(len(kouho)):
        if div[i] % kouho[x] == 0:
            break
    else:
        kouho.append(div[i])
print(len(kouho)+1)


Measured memory_bytes: 3280
#include<stdio.h>

int gcd(int a, int b){
        if(a<b){
                a ^= b;
                b ^= a;
                a ^= b;
        }
        while(b){
                int tmp = b;
                b = a%b;
                a = tmp;
        }
        return a;
}


int main(void){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        printf("%d\n", a/gcd(a,b)*b/gcd(a,b)*c);
        return 0;
}


Measured memory_bytes: 2148
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main(){
	int N, F[100][5][2], P[100][11];
	cin >> N;
	REP(i, N){
		REP(j, 5){
			REP(k, 2){
				cin >> F[i][j][k];
			}
		}
	}
	REP(i, N){
		REP(j, 11){
			cin >> P[i][j];
		}
	}

	int ans = -1e+9;
	REP(i, (1 << 10)){
		int c[100] = { 0 }, t = 0;
		if (i == 0){
			continue;
		}
		REP(j, 10){
			if (i >> j & 1){
				REP(k, N){
					if (F[k][j / 2][j % 2] == 1){
						c[k]++;
					}
				}
			}
		}
		REP(k, N){
			t += P[k][c[k]];
		}
		ans = max(ans, t);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define FBO find_by_order
#define OOK order_of_key
#define mset(m,v) memset((m),(v),sizeof(m))
#define inrep int TC;cin>>TC;while(TC--)
#define cppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PI 3.1415926535897932384626433832795028841971693993751
#define trace1(x) cerr<<#x<<": "<<x<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n"
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// SOLUTION

int main() {
	cppio;
	int n;
	cin >> n;
	ll a[n + 10], b[n + 10];
	mset(a, 0);
	mset(b, 0);
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 1; i <= n; i++) a[i] += a[i - 1];
	for(int i = 1; i <= n; i++) b[i] += b[i - 1];
	ll ans = 0;
	for(int i = 1; i <= n; i++) ans = max(ans, a[i] + b[n] - b[i - 1]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

template<class T>
class SegTree {
    int n;
    vector<T> dat;
    T id;
    function<T(T,T)> op;
    function<T(T,T)> update;

    T query_(int a, int b, int k, int l, int r) {
        if(r<=a || b<=l) return id;
        if(a<=l && r<=b) return dat[k];
        T c1 = query_(a,b,2*k+1,l,(l+r)/2);
        T c2 = query_(a,b,2*k+2,(l+r)/2,r);
        return op(c1,c2);
    }
public:
    SegTree(int n_, T id_, function<T(T,T)> op_, function<T(T,T)> update_)
        : id(id_), op(op_), update(update_) {
            n = 1;
            while(n<n_) n*=2;
            dat = vector<T>(2*n-1, id);
    }

    void change(int i, T x) {
        i += n - 1;
        dat[i] = update(dat[i], x);
        while(i>0) {
            i = (i-1)/2;
            dat[i] = op(dat[2*i+1], dat[2*i+2]);
        }
    }

    T query(int a, int b) {return query_(a,b,0,0,n);}

    T operator[](int i) {return dat[i+n-1];}
};

ll gcd(ll x, ll y) {
    if(y==0)return x;
	if(x%y==0) return y;
	return gcd(y,x%y);
}

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    function<ll(ll,ll)> update = [](ll, ll y){return y;};
    SegTree<ll> ST(N,0LL,gcd,update);
    REP(i,N) ST.change(i,A[i]);
    ll ans = 0;
    REP(i,N){
        ll a = ST[i];
        ST.change(i,0LL);
        ans = max(ans, ST.query(0,N));
        ST.change(i,a);
    };
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3072
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
a.append(-1)
idx = 0
mod = 10**9+7
dp = [0]*(n+1)

dp[0] = 1
if a[idx] == 1: idx += 1
else: dp[1] = 1

for i in range(2,n+1):
    if i == a[idx]: idx += 1
    else: dp[i] = (dp[i-1] + dp[i-2])%mod

print(dp[n])

Measured memory_bytes: 7824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(){
ll  k, n;
cin  >> k >> n;
vector<ll> a(n), b(n);
ll mx = 0;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++) {
    if(i == n-1) b[i] = a[0]+(k-a[n-1]);
    else  b[i] = a[i+1] - a[i];
    mx = max(mx, b[i]);
}
cout << k -mx << endl;
return 0;
}

Measured memory_bytes: 6372
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<pair<int,int> > dp(k+1);
    dp[0]={0,0};
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            int val=arr[j];
            if(i>=val)
            {
                if(dp[i-val].second==0)
                dp[i].first=1;
                if(dp[i-val].first==0)
                dp[i].second=1;
            }
        }
    }
    // for(int i=0;i<=k;i++)
    // {
    //     cout<<dp[i].first<<dp[i].second;
    //     cout<<" ";
    // }
    if(dp[k].first)
    cout<<"First";
    else
    cout<<"Second";
}

Measured memory_bytes: 3668
n = int(input())
dpa = [0 for i in range(n)]
dpb = [0 for i in range(n)]
dpc = [0 for i in range(n)]
a,b,c = map(int, input().split())
dpa[0] = a
dpb[0] = b
dpc[0] = c
for i in range(1,n):
    a, b, c = map(int, input().split(" "))
    dpa[i] = max(dpb[i-1], dpc[i-1]) + a
    dpb[i] = max(dpa[i-1],dpc[i-1]) + b
    dpc[i] = max(dpb[i-1], dpa[i-1]) + c
print(max(dpa[n-1], dpb[n-1], dpc[n-1]))

Measured memory_bytes: 51888
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int edge[99999][2];

int qmem[199998];

int n;

int *e[100000];
int el[100000];

int p[100000];

int f(int now, int from, int k){
	if(now==n-1) return 1;
	if(el[now]==1 && e[now][0]==from) return 0;
	for(int i=0; i<el[now]; i++){
		int to=e[now][i];
		if(to!=from){
			int v=f(to, now, k+1);
			if(v>0){
				if(v>=k){
					p[now]=1;
				}else{
					p[now]=2;
				}
				return v+1;
			}
		}
	}
	return 0;
}

void g(int now, int from, int x){
	if(el[now]==1 && e[now][0]==from) return;
	for(int i=0; i<el[now]; i++){
		int to=e[now][i];
		if(to!=from){
			if(p[to]==0){
				p[to]=x;
				g(to, now, x);
			}else{
				g(to, now, p[to]);
			}
		}
	}
}

int main(void){
	n=nextint();
	for(int i=0; i<n-1; i++){
		int A=nextint()-1;
		int B=nextint()-1;
		edge[i][0]=A;
		edge[i][1]=B;
		el[A]++;
		el[B]++;
	}
	int ne=0;
	for(int i=0; i<n; i++){
		e[i]=&qmem[ne];
		ne+=el[i];
		el[i]=0;
	}
	for(int i=0; i<n-1; i++){
		int A=edge[i][0];
		int B=edge[i][1];
		e[A][el[A]++]=B;
		e[B][el[B]++]=A;
	}
	f(0, -1, 0);
	p[n-1]=2;
	g(0, -1, 1);
	//for(int i=0; i<n; i++){ printf("%d ", p[i]); } putchar(10);
	int a=0;
	for(int i=0; i<n; i++){
		if(p[i]==1) a++; else a--;
	}
	puts(a>0?"Fennec":"Snuke");
}


Measured memory_bytes: 9472
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std; 

#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/

void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}

unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];

    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}
   
int main(){
    int X;

    cin>>X;
    while(!sosu_judge(X)) X++;
    cout<<X<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]

d = {}
for i in a:
    if i in d:
        if d[i] == 0:
            d[i] = 1
        else:
            d[i] = 0
    else:
        d[i] = 1

print(list(d.values()).count(1))


Measured memory_bytes: 16268
#include <bits/stdc++.h>
using namespace std;
const int mod=round(1e9)+7;
int f[302][302][302],i,l,r,k,n,m;
struct pt { int l,k; };
vector <pt> vec[302];
bool check(int v1,int v2,int v3)
{
    int i=max(v1,max(v2,v3));
    for(int j=0;j<vec[i].size();j++)
    {
        int l=vec[i][j].l,k=vec[i][j].k;
        int t=(v1>=l)+(v2>=l)+(v3>=l);
        if(t!=k) return 0;
    }
    return 1;
}
int tinh(int v1,int v2,int v3)
{
    if(f[v1][v2][v3]>-1) return f[v1][v2][v3];
    if(check(v1,v2,v3)==0) return f[v1][v2][v3]=0;
    int i=max(v1,max(v2,v3))+1;
    if(i>n) return 1;
    int kq=0;
    kq=(kq+tinh(i,v2,v3))%mod;
    kq=(kq+tinh(v1,i,v3))%mod;
    kq=(kq+tinh(v1,v2,i))%mod;
    return f[v1][v2][v3]=kq;
}
int main()
{
   // freopen("ntu.inp","r",stdin);
   // freopen("ntu.out","w",stdout);
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>l>>r>>k;
        vec[r].push_back({ l,k });
    }
    memset(f,-1,sizeof(f));
    cout<<tinh(0,0,0);
}


Measured memory_bytes: 107904
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
main(){
    int N,A[300000];
    cin >> N;
    for(int i = 0;i < N*3;i++)cin >> A[i];
    sort(A,A+N*3);
    ll sum = 0;
    for(int i = N*3-2,j = 0;j < N;i-=2,j++){
        sum += A[i];
    }
    cout << sum << endl;
}

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

public class Main {

	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}

	private long solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long [] array = new long[N+1];
		long sum =0;
		for(int i=1;i<=N;i++){
			array[i] = sc.nextLong();
			sum+= array[i];
		}

		long [][] dp = new long[3002][3002];

		long X = solve(dp, array,1, N, 1);
		long Y = sum-X;
		return X-Y;
	}

	private long solve(long[][] dp, long[] array, int left, int right, int turn) {

		if(left>right) return 0;
		if (dp[left][right]!=0) return dp[left][right];
		long answer=0;
		if (turn==1) {
			long choose_left = array[left] + solve(dp, array, left+1, right, 0);
			long choose_right = array[right] + solve(dp, array, left, right-1, 0);
			answer = Math.max(choose_right, choose_left);
		} else {
			long choose_left = solve(dp, array, left+1, right, 1);
			long choose_right = solve(dp, array, left, right-1, 1);
			answer = Math.min(choose_left, choose_right);			 
		}
		dp[left][right] = answer;
		return answer;
	}

}

Measured memory_bytes: 109560
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n,ans=0;
    string s;
    cin>>s;
    for(i=0;s[i];i++){
        if(s[i]=='1') ans++;

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





Measured memory_bytes: 3608
s = input()

n = len(s)

s1 = s[0:(n-1)//2]
s2 = s[(n+3)//2-1:]


reversed_s = list(reversed(list(s)))
reversed_s1 = list(reversed(list(s1)))
reversed_s2 = list(reversed(list(s2)))


if s == ''.join(reversed_s) and s1 == ''.join(reversed_s1) and s2 == ''.join(reversed_s2):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;

typedef complex<int> P;

int b[19][19];

int main(){
	
	int n,m;
	map<string,int> a;
	while(cin>>n,n!=0){
	string s;
	int p;
	for(int i=0;i<n;i++){
		cin>>s>>p;
		a[s]=p;
	}
	string o;
	int k;
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>o>>k;
		string q;
		long long temp=0;
		for(int j=0;j<k;j++){
			cin>>q;
			temp+=a[q];
		}
		if(a[o]>temp)
			a[o]=temp;
	}
	string t;
	cin>>t;
	cout<<a[t]<<endl;
	}
	
}

Measured memory_bytes: 3220
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n;
  ll k;
  int a,b;
  pair<int,int> ab[SIZE] = {};
  
  scanf("%d%lld",&n,&k);

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

  sort(ab,ab+n);

  ll sum = 0;
  
  for(int i=0;i<n;i++){
    sum += ab[i].second;

    if(sum >= k){
      printf("%d\n",ab[i].first);
      return 0;
    }
  }

  assert(false);
  
  return 0;
}


Measured memory_bytes: 1024
/*-----lusar98-----*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
int main()
{
    //fast();
	ll n,k;
    cin>>n>>k;
    vector<ll> arr(n);
    for(ll i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    bool dp[k+2]={0};
    dp[0]=0;
    for(ll i=1;i<=k;i++)
    {
    	for(ll j = 0 ; j < n ; j++ )
    	{
    		if( i >= arr[j] && !dp[i] )
    			dp[i]  = !dp[ i - arr[j] ];
    	}
    }
    // for(ll i=0;i<=k;i++)
    // 	cout<<dp[i]<<" ";
    cout<< (!dp[k] ? "Second" : "First" )<<endl;    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int x=0;
  int k=0;
  
  for(int i=0;i<n;i++){
    if(s.at(i)=='I')
      x++;
    else
      x--;
    k=max(k,x);
  }
  cout << k << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  long long a,b;
  cin >> a >> b;
  if(a*b<=0){
    cout << "Zero" << endl;}
  else if(a>0){
    cout << "Positive" << endl;}
  else if((b-a)%2==0){
    cout << "Negative" << endl;}
  else{
    cout << "Positive" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}
 
void scerr(vi nums) {
	for (auto it : nums)
		cerr << it << " | ";
	cerr << "\n";
}
 
int n, m, dp[N], ans = -1;
vi g[N];

int dfs(int v) {
	if (dp[v])
		return dp[v]; 
	for (auto to : g[v]) {
		dp[v] = max(dp[v], dfs(to) + 1);
		ans = max(ans, dp[v]);
	}
	return dp[v];
}
 
int main() {
	data();
	scanf("%d %d", &n, &m);
	while (m--) {
		int x, y;
		scanf("%d %d", &x, &y);
		g[x].pb(y);
	}
	for (int i = 1; i <= n; ++i)
		if (!dp[i])
			dfs(i);
	printf("%d", ans);
	return 0;
}
 
/*
	Timus: 288481RF
	CodeForces: __fractal
*/

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

char a[10][10];

int main(){
    int h,w;
    cin >> h >> w;
    REP(i,h){
        REP(j,w){
            cin >> a[i][j];
        }
    }
    bool flag = true;
    REP(i,h-1){
        REP(j,w-1){
            if(a[i+1][j]=='#'&&a[i][j+1]=='#')flag = false;
        }
    }
    if(flag){
        put("Possible");
    }else{
        put("Impossible");
    }
    return 0;
}


Measured memory_bytes: 256
using System;

namespace Aizu
{
    public class OnlineJuedge
    {
        public static void Main()
        {
            var array = new int [101];
            var max = 0;
            for(string input; (input = Console.ReadLine()) != null;) {
                max = Math.Max(++array[int.Parse(input)], max);
            }
            for(int i = 1; i <= 100; ++i){
                if(max == array[i]) {
                    Console.WriteLine(i);
                }
            }
        }
    }
}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    string ans;
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='B'){
            if(ans.size()==0)continue;
            ans.pop_back();
            continue;
        }
        ans.push_back(s.at(i));
    }
    cout<<ans<<endl;
}



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

int main() {
  int n;
  long ans = 0;

  cin >> n;

  for (size_t i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }

  cout << ans;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n,K;
ll a[101010],b[101010];

int main(){
	cin>>n>>K;
  rep(i,n)cin>>a[i]>>b[i];
  ll res=0;
  rep(i,n){
    if((a[i]&K)==a[i])res+=b[i];
  }
  rep(i,32){
    if(((K>>i)&1LL)==0)continue;
    ll sum=0;
    ll nK=K^(1LL<<i);
    nK|=(1LL<<i)-1;
    rep(i,n){
      if((a[i]&nK)==a[i])sum+=b[i];
    }
    maxch(res,sum);
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;

int main(){
    ll a=0,b=0,c=0,d=0,ans=0,ret=M,n,m;
	string s;
	bool x = false;
	cin >> n;
	vll dp(n+1),w(n+1);
	REP(i,1,n+1) cin >> w[i];
	if(n == 1){
		cout << w[1] << endl;
		goto exit;
	}
	w[0] = M;
	//REP(i,1,n+1) cout << w[i];
	REP(i,2,n+1){
		dp[i] = min(abs(abs(w[i] - w[i-2]) + dp[i-2]), abs(abs(w[i] - w[i-1]) + dp[i-1]));
		//cout << i << " " << dp[i] << endl;
	}
	//rep(i,n+1) cout << dp[i] << " ";
	//cout << endl;
	cout << dp[n] << endl;
	exit:
    return 0;
}  


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

int main(){
    int n;
    map<string, int> cnt;
    cin >> n;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        --cnt[s];
    }

    vector<pair<int, string>> ans;
    for(auto p: cnt){
        if(p.second < 0) ans.emplace_back(p.second, p.first);
    }
    sort(ans.begin(), ans.end());

    for(auto p: ans){
        if(p.first > ans.front().first) break;
        cout << p.second << endl;
    }
        
    return 0;
}

Measured memory_bytes: 29552
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, C;
ll d[30][30], c[500][500];
ll masu[3][30];

int main() {
	cin >> n >> C;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> d[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> c[i][j];
		}
	}

	//色でまとめる
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			masu[(i + j) % 3][c[i][j]-1]++;
		}
	}
	/*for (int i = 0; i < 3; i++) {
		for (int j = 0; j < C; j++) {
			cout << masu[i][j] << " ";
		}
		cout << endl;
	}*/


	ll ans = INT32_MAX;
	if (n == 1)ans = 0;

	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			if (i == j)continue;
			for (int k = 0; k < C; k++) {
				
				if (i == k || j == k)continue;
				ll sum = 0;

				//cout << "i:" << i << " j:" << j << " k:" << k << endl;

				for (int l = 0; l < C; l++) {
					sum += d[l][i] * masu[0][l];
				}
				for (int l = 0; l < C; l++) {
					sum += d[l][j] * masu[1][l];
				}
				for (int l = 0; l < C; l++) {
					sum += d[l][k] * masu[2][l];
				}

				ans = min(ans, sum);
			}
		}
	}
	

	cout << ans << endl;
}

Measured memory_bytes: 2176
S=input()
T=input()

A=len(S)
B=len(T)

if A<B:
    print("UNRESTORABLE")
    exit()

X=[]
for i in range(A-B+1):
    U=S[i:i+B]

    F=True
    for k in range(B):
        F&=(U[k]=="?" or U[k]==T[k])

    if F:
        Y=S[:i]+T+S[i+B:]
        Y=Y.replace("?","a")
        X.append(Y)

if X:
    print(min(X))
else:
    print("UNRESTORABLE")

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

int main() {
  double R, A, G;
  cin >> R >> G;
  if( R < 0 ){ 
  	cout << "error: R under 0" << endl;
    return 1;
  }
  else if( G > 4500 ){
  	cout << "error: G over 4500" << endl;
    return 1;
  }
  cout << (G*2) - R << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
int main()
{
	io
	int m ,n;
	cin>>n>>m;
	priority_queue<int> heap;
	double sum = 0;
	for(int i = 0; i<n; i++)
	{
		int x;
		cin>>x;
		heap.push(x);
		sum += x;
	}
	float bar = sum/(float)(4*m);
	//cout<<"Bar"<<bar<<endl;
	bool flag = true;
	while(m-- && !heap.empty())
	{
		if(heap.top() < bar)
		{
			flag = false;
			break;

		}
		else 
		{
			heap.pop();
		}
	}
	if(flag)
		cout<<"Yes";
		else cout<<"No";
	
}


Measured memory_bytes: 256
from collections import deque
N,Q = map(int,input().split())
tree = [[] for _ in range(N+1)]
counter = [0]*(N+1)
for i in range(N-1):
    a,b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
for i in range(Q):
    p,x = map(int,input().split())
    counter[p] += x
parent = [0]*(N+1)
d = deque([1])

while d:
    a = d.popleft()
    for b in tree[a]:
        if parent[a] == b:
            continue
        counter[b] += counter[a]
        parent[b] = a
        d.append(b)

print(*counter[1:])



Measured memory_bytes: 58312
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ak = min(a, k);
  k -= ak;
  int bk = min(b, k);
  k -= bk;
  cout << ak - k << endl;
  return 0;
}

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

int main() {

    int a,b;
    
    for(int i = 0; ; i++){
        cin >> a >> b;
        if(a == 0 && b == 0)break;
        for(int i = 0;i < a ; i++){
            for(int i = 0;i < b ; i++){
                if(i == b-1){
                    cout << "#" << endl;
                }
                if(i < b-1)cout << "#";
            }
            if(i == a-1){
                cout << endl;
            }
        }
    }

}


Measured memory_bytes: 3088
#include <stdio.h>
#include <math.h>

#include <iostream>
#include <vector>
#include <algorithm>

int A, B;
std::string S, T, U;

char s[100], t[100], u[100];

int main()
{
	scanf("%s %s", s, t);
	scanf("%d %d", &A, &B);
	scanf("%s", u);

	S = s;
	T = t;
	U = u;

	if( S == U ) A--;
	if( T == U ) B--;

	int w_tmp = 0, h_tmp = 0;
	int w_sta = -1;

	printf("%d %d\n", A, B);

	return 0;
}


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

int main()
{
    int inf = 10000000;
    vector<pair<int, int> > red;
    vector<pair<int, int> > blue;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        pair<int, int> in;
        cin >> in.second >> in.first;
        red.push_back(in);
    }
    for(int i = 0; i < n; i++){
        pair<int, int> in;
        cin >> in.first >> in.second;
        blue.push_back(in);
    }
    sort(red.begin(), red.end(), greater<pair<int, int> >());
    sort(blue.begin(), blue.end());
    for(int i = 0; i < n; i++){
        int copy = red[i].first;
        red[i].first = red[i].second;
        red[i].second = copy;
    }
    /*for(int i = 0; i <= 2; i++){
        cout << blue[i].first << " " << blue[i].second << endl;
        }*/
    int answer = 0;
    for(int j = 0; j < n; j++){
        for(int i = 0; i < n; i++){
            if((red[i].first < blue[j].first) && (red[i].second < blue[j].second)){
                red[i].second = inf;
                answer++;
                break;
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    cout << N / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

int k, n, mx, s, a[N];
int main()
{
	int i, t;
	cin >> k >> n;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	a[n] = a[0] + k;
	for (i = 1; i <= n; i++) {
		t = a[i] - a[i - 1];
		s += t;
		mx = max(mx, t);
	}
    cout << s - mx << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if (k < e - a)
        cout << ":(";
    else
        cout << "Yay!";
}


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

int main(){
	int n, m[100], a[100], b[100];
	
	while( cin >> n , n ){
		for(int i=0 ; i < n ; i++ ){
			cin >> m[i] >> a[i] >> b[i];
		}
		
		bool flag = false;
		for(int i=0 ; i < n ; i++ ){
			int t = a[i];
			int weight = 0;
			for(int j=0 ; j < n ; j++ ){
				if( a[j] <= t && t < b[j] ){
					weight += m[j];
				}
			}
			if( 150 < weight ){
				flag = true;
			}
		}
		if( flag )
			cout << "NG" << endl;
		else 
			cout << "OK" << endl;
	}
}

Measured memory_bytes: 0
w, h, n = [int(i) for i in input().split()]
x = []
y = []
a = []
for i in range(n):
    tmp = [int(i) for i in input().split()]
    x.append(tmp[0])
    y.append(tmp[1])
    a.append(tmp[2])

p1 = [0, 0]
p2 = [w, h]

for i in range(n):
    if a[i] == 1:
        p1[0] = max(p1[0], x[i])
    elif a[i] == 2:
        p2[0] = min(p2[0], x[i])
    elif a[i] == 3:
        p1[1] = max(p1[1], y[i])
    else:
        p2[1] = min(p2[1], y[i])

if p1[0] >= p2[0] or p1[1] >= p2[1]:
    print(0)
else:
    print((p2[0] - p1[0]) * (p2[1] - p1[1]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i <3; i++) {
    if (s.at(i) == '1') {
      count++;
    }
  }
 cout << count << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
H, W, K = map(int, input().split())
B = {}
for _ in range(K):
    r, c, v = map(int, input().split())
    B[(r, c)] = v

dp = [[0]*(W+1) for _ in range(4)]

for i in range(1, H+1):
    for j in range(1, W+1):
        if (i, j) in B:
            v = B[(i, j)]
            dp[0][j] = max(dp[0][j-1], dp[0][j], dp[1][j], dp[2][j], dp[3][j])
            dp[1][j] = max(dp[1][j-1], dp[0][j]+v)
            dp[2][j] = max(dp[2][j-1], dp[1][j-1]+v)
            dp[3][j] = max(dp[3][j-1], dp[2][j-1]+v)
        else:
            dp[0][j] = max(dp[0][j-1], dp[0][j], dp[1][j], dp[2][j], dp[3][j])
            dp[1][j] = dp[1][j-1]
            dp[2][j] = dp[2][j-1]
            dp[3][j] = dp[3][j-1]

print(max(dp[i][-1] for i in range(4)))


Measured memory_bytes: 108148
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}
const int n_max = 1010101;
int A[n_max];


signed main(){
    int m,k;
    cin >> m >> k;
    if(m == 1){
        if(k >= 1){
            cout << -1 << endl;
        }
        else{
            cout << "1 1 0 0" << endl;
        }

        return 0;
    }
    int n = 1 << m;
    if(n <=k){
        cout << - 1 << endl;
        return 0;
    }
    A[0] = k;
    int id = 1;
    REP(i,n){
        if(i != k){
            A[id] = i;
            id ++;
        }
    }
    A[id] = k;
    id ++;
    REPR(i,n-1){
        if(i != k){
            A[id] = i;
            id ++;
        }
    }

    REP(i,2 * n){
        cout << A[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 string a,b,c;
 cin>>a>>b>>c;
 cout<<a[0]<<b[1]<<c[2]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  if(b-a==c-b){
    print("YES");
  }
  else{
    print("NO");
  }
}

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

using namespace std;

void hawawa()
{
  long long x;
  cin >> x;
  long long ans = x / 11 * 2;
  if (x % 11 == 0) {
    cout << ans << "\n";
  } else if (x % 11 <= 6) {
    cout << ans + 1 << "\n";
  } else {
    cout << ans + 2 << "\n";
  }
}

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

Measured memory_bytes: 256
MOD = 1000003
fac = [1] * (10 ** 6 * 3)
for i in range(len(fac) - 1):
    fac[i + 1] = fac[i] * (i + 1) % MOD
q = int(input())
for _ in range(q):
    x, d, n = map(int, input().split())
    if x == 0:
        print(0)
    elif d == 0:
        print(pow(x, n, MOD))
    elif n >= MOD:
        print(0)
    else:
        x = x * pow(d, MOD - 2, MOD) % MOD
        print(fac[x + n - 1] * pow(fac[x - 1], MOD - 2, MOD)
              * pow(d, n, MOD) % MOD)


Measured memory_bytes: 74716
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String t = scan.nextLine();

		char[] sChars = s.toCharArray();
		char[] tChars = t.toCharArray();
		long N = s.length();

		// アルファベット分TreeSetを用意
		TreeSet<Integer>[] sets = new TreeSet[26];
		for (int i = 0; i < sets.length; i++) {
			sets[i] = new TreeSet<Integer>();
		}

		// アルファベットに要素順を設定
		for (int i=0; i < sChars.length; i++) {
			sets[sChars[i] - 'a'].add(i);
		}

		int lastIndex = 0;
		long ans = 0;
		for (char c : tChars) {
			Integer tmpIndex = sets[c - 'a'].ceiling(lastIndex);
			if (tmpIndex == null) {
				lastIndex = 0;
				ans += N;
				tmpIndex = sets[c - 'a'].ceiling(lastIndex);
				if (tmpIndex == null) {
					System.out.println(-1);
					return;
				}
			}
			lastIndex = tmpIndex + 1;
		}
		ans = ans + (long)(lastIndex);
		System.out.println(ans);
	}
}


Measured memory_bytes: 36304
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    A_str, B_str = input().split()

    A = int(A_str)
    B100 = int(B_str.replace(".", ""))

    answer = (A*B100)//100
    print(answer)

if __name__ == "__main__":
    main()



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

m1=0
m2=0

A=[]

for i in range(N):
    a=int(input())
    if a>m1:
        m1=a
    elif a>m2:
        m2=a
    A.append(a)

for i in range(N):
    if A[i]==m1:
        print(m2)
    else:
        print(m1)
    



Measured memory_bytes: 12532
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

ans_index = 0
total = sum(P[0:K])
prev = total
for i in range(N-K):
    tmp = prev + P[i+K] - P[i]
    if tmp > total:
        total = tmp
    prev = tmp

print((total + K) * 0.5)


Measured memory_bytes: 71792
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

#define maxW 100010
#define maxN 102
#define maxV 100000

#define INFINITY 99999999999999

typedef long long ll;

int n;
ll s;
ll cache[maxN][maxW], v[maxN], w[maxN];

ll rec(int i, int V) {
    if (V == 90) {
        int a = 0;
    }
    if (V == 0) {
        return 0;
    }
    if (i == 0 && V == v[i]) {
        return w[i];
    }
    if (i <= 0 || V < 0) return INFINITY;
    if (cache[i][V] != -1) return cache[i][V];
    if (v[i] > V) return cache[i][V] = rec(i-1, V);
    return cache[i][V] = min(rec(i-1, V), w[i] + rec(i-1, V-v[i]));
}

int main() {
    cin >> n >> s;
    for (int i = 0; i<n; i++) {
        cin >> w[i] >> v[i];
        for (int j = 0; j<maxW; j++) {
            cache[i][j] = -1;
        }
    }
    for (int i = maxV; i>=0; i--) {
        ll w = rec(n-1, i);
        if (w <= s) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, 1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << "Line " << __LINE__ <<": " << x << nl
#define pb push_back
#define nl "\n"
#define sp " "

#define _ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define file() freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout)

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

const int N = 1e6+2;

int tc = 1;

int n, k, q, b, c, freq[N];
ll ans = 0;

int main(){_

   	//file();

   	//cin >> tc;

    while(tc--){

    	cin >> n;

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

    		cin >> k;
    		freq[k]++;
    		ans += k;
    	}

    	cin >> q;

    	while(q--){

    		cin >> b >> c;

    		ans -= (1LL*freq[b]*b);
    		freq[c] += freq[b];
    		ans += 1LL*freq[b]*c;
    		freq[b] = 0;

    		cout << ans << nl;
    	}
    	
    }
    

    return 0;
}


Measured memory_bytes: 4048
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	sum := 0
	for i := 1; i <= n; i++ {
		if i % 3 == 0 || i % 5 ==0 {
			continue
		}
		sum += i
	}
	fmt.Println(sum)
}

Measured memory_bytes: 1752
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

#include <bits/extc++.h>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>,
  rb_tree_tag, tree_order_statistics_node_update>;

// cur.order_of_key(2)
// the number of elements in the set less than 2
// *cur.find_by_order(1)
// the 1-st smallest number in the set(0-based)


const int MAX_N = 2e5 + 5;

ll a [MAX_N], b [MAX_N], c [MAX_N];

ll x, y, z;

ll xsum, ysum;
ordered_set<pair<ll, ll>> cur_xs; // <C[i] - A[i], i>

void add_x (ll idx) {
  cur_xs.insert(make_pair(c[idx] - a[idx], idx));

  if ((ll) cur_xs.order_of_key(make_pair(c[idx] - a[idx], idx)) < x) {
    xsum += a[idx] - c[idx];

    ll pos = cur_xs.find_by_order(x) -> second;
    xsum -= a[pos] - c[pos];
  }
}

void del_x (ll idx) {
  ll flag = 0;
  if ((ll) cur_xs.order_of_key(make_pair(c[idx] - a[idx], idx)) < x) {
    xsum -= a[idx] - c[idx];
    flag = 1;
  }

  cur_xs.erase(make_pair(c[idx] - a[idx], idx));

  if (flag) {
    ll pos = cur_xs.find_by_order(x - 1) -> second;
    xsum += a[pos] - c[pos];
  }
}

ordered_set<pair<ll, ll>> cur_ys; // <C[i] - B[i], i>

void add_y (ll idx) {
  cur_ys.insert(make_pair(c[idx] - b[idx], idx));

  if ((ll) cur_ys.order_of_key(make_pair(c[idx] - b[idx], idx)) < y) {
    ysum += b[idx] - c[idx];

    ll pos = cur_ys.find_by_order(y) -> second;
    ysum -= b[pos] - c[pos];
  }
}

const ll INF = 1e12 + 5;

int main () {
  cin >> x >> y >> z;

  ll n = x + y + z;
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    ans += c[i];
  }

  for (ll i = n; i < 2 * n; i++) {
    c[i] = INF;
    cur_xs.insert(make_pair(c[i] - a[i], i));
    cur_ys.insert(make_pair(c[i] - b[i], i));
  }

  xsum = -x * INF;
  ysum = -y * INF;

  for (ll i = 0; i < n; i++) {
    add_x(i);
  }

  vector<pair<ll, ll>> ord;
  for (ll i = 0; i < n; i++) {
    ord.push_back(make_pair(a[i] - b[i], i));
  }
  sort(ord.begin(), ord.end());
  
  ll mx = -1e18;
  for (ll i = 0; i < n; i++) {
    del_x(ord[i].second);
    add_y(ord[i].second);

    /*
    prllos(cur_xs);
    prllos(cur_ys);
    */

    mx = max(mx, xsum + ysum);
  }

  cout << ans + mx << endl;
}


Measured memory_bytes: 25336
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        s = s.replaceAll("eraser" , "");
        s = s.replaceAll("erase", "");
        s = s.replaceAll("dreamer", "");
        s = s.replaceAll("dream", "");

        if(s.length() != 0) System.out.println("NO");
        else System.out.println("YES");
    }
}


Measured memory_bytes: 29648
#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 H, A;
  cin >> H >> A;
  int ans = H / A;
  if (H % A == 0) {
    cout << ans << endl;
  }
  else {
    ans ++;
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
  int A, B;
  
  cin >> A >> B;
  if(A >= 13){
    cout << B << endl;
  }else if(6 <= A && A <= 12){
    cout << (B / 2) << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,ans,h,w,temp,d[100];
string e;
int main(){
    cin>>e;
    for(int i=0;i<e.length();i++){
        if(e[i]=='A'||e[i]=='T'||e[i]=='C'||e[i]=='G')d[i]=1;
    }
    for(int i=0;i<e.length();i++){
        if(d[i]==1)temp+=1;
        if(i==e.length()-1||d[i]==0){ans=max(ans,temp);temp=0;}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
int main()
{
    cin>>n;
    vector<int> h(n+1);
    vector<int> dp(n+1);
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]));
    //for(int i=1;i<=n;i++)
    //    printf("%d ",dp[i]);
    printf("%d\n",dp[n]);
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int M = sc.nextInt();
      
      int arrayA[] = new int[A];
      for(int i = 0; i < A; i++){
        arrayA[i] = sc.nextInt();
      }
      
      int arrayB[] = new int[B];
      for(int i = 0; i < B; i++){
        arrayB[i] = sc.nextInt();
      }
      
      int arrayX[] = new int[M];
      int arrayY[] = new int[M];
      int arrayC[] = new int[M];
      for(int i = 0; i < M; i++){
        arrayX[i] = sc.nextInt();
        arrayY[i] = sc.nextInt();
        arrayC[i] = sc.nextInt();
      }
      
      // 割引券未使用時の最小金額
      int minA = Integer.MAX_VALUE;
      int minB = Integer.MAX_VALUE;
      for(int i = 0; i < A; i++){
        int price = arrayA[i];
        if(price < minA){
          minA = price;
        }
      }
      
      for(int i = 0; i < B; i++){
        int price = arrayB[i];
        if(price < minB){
          minB = price;
        }
      }
      
      int min = minA + minB;
      
      // 割引券使用時の最小金額
      for(int i = 0; i < M; i++){
        int price = arrayA[arrayX[i]-1] + arrayB[arrayY[i]-1] - arrayC[i];
        if(price < min){
          min = price;
        }
      }
      
      // 出力
      System.out.println(min);
    }

}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{   
    string S;
    cin >> S;
    ull n = 0;
    ull nW = 0;
    for(ll i=0;i<S.size();i++){
        if(S.at(i) != 'W') continue;
        n += i - nW;
        nW++;
    }
    cout<<n<<endl;

    return 0;
}

Measured memory_bytes: 640