akhauriyash/Code-Regression huggingface dataset:
var
  n,k,t,i:longint;
  a,sum:array[0..300000] of extended;
  ans:extended;
begin
  readln(n,k);
  for i:=1 to n do
  begin
    read(t);
    a[i]:=(1+t)*t div 2/t;
    sum[i]:=sum[i-1]+a[i];
  end;
  for i:=k to n do
  if sum[i]-sum[i-k]>ans then ans:=sum[i]-sum[i-k];
  writeln(ans:0:12);
end.

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[100000][3]={};
    dp[0][0] = a[0], dp[0][1]=b[0], dp[0][2]=c[0]; 
    for(int i=1;i<n;i++){
        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]); //i日目でaを選んだ場合の最大
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define tr1(x)                cout<<#x<<": "<<x<<endl
#define tr2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define tr4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define tr3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db1(x) cerr << #x << ": " << x <<'\n'
#define db2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define db3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<pair<string,int>, int> &a,const pair<pair<string,int>, int> &b)
{
    if(a.ff.ff == b.ff.ff) {
        return (a.ff.ss > b.ff.ss);
    }
    return (a.ff.ff<b.ff.ff);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b, int c){
    return(max( max(a,b), c ));
}
int min(int a, int b, int c){
    return (min ( min(a,b) , c));
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;
 
    return res;
}
int findlcm(int arr[], int n)
{
    // Initialize result
    int ans = arr[0];
 
    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (__gcd(arr[i], ans)));
 
    return ans;
}
bool prime[100001];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
 
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}
 
//Define mx for maximum range and MOD for large numbers
#define mx 500005
#define mod 1000000007
 
// Declare all the variables and global functions here -
int n;
int a[101] = {0};
int32_t main(){
    IOS;
    double w,h,x,y;
    cin >>w>> h >> x >> y;
    double ans = w*h;
    ans /= 2;
    cout << setprecision(12) << ans << " ";
    if(x == w/2 && y == h/2){
        cout << 1;
    }
    else{
        cout << 0;
    }
}  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	long long x, y, z, e, m;
	while (cin >> e&&e != 0) {
		m = 1000000000000000000;
		for (z = ceil(sqrt(e)); z >= 0; z--) {
			if (z*z*z <= e) {
				for (y = ceil(sqrt(e - z*z*z)); y >= 0; y--) {
					if (z*z*z + y*y <= e) {
						x = e - z*z*z - y*y;
						m = min(x + y + z, m);
					}
				}
			}
		}
		cout << m << endl;
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, h, mxa = 0, btot = 0, ans = 0;
  cin >> n >> h;
  vector<ll> a(n), b(n), nb;
  rep(i, n) {
    cin >> a[i] >> b[i];
    mxa = max(mxa, a[i]);
  }

  sort(b.rbegin(), b.rend());
  rep(i, n) {
    if (b[i] > mxa) {
      nb.emplace_back(b[i]);
      btot += b[i];
    }
  }

  if (h > btot) {
    while (h > btot) {
      h -= mxa;
      ans++;
    }
    int i = 0;
    while (h > 0) {
      h -= b[i];
      ans++;
      i++;
    }
  } else {
    int i = 0;
    while (h > 0) {
      h -= b[i];
      ans++;
      i++;
    }
  }

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


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

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

    vector<bool> broken(N+1);
    for (int i = 0; i < M; ++i) {
        int a ;
        cin >> a;
        broken[a] = true;
    }

    vector<int> dp(N+2);
    const int mod = 1000000007;
    dp[N] = 1;
    for (int i = N-1; i >= 0; --i) {
        if (broken[i]) {
            dp[i]=0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }
    cout << dp[0] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    int a,b,c;
    cin >> a >> b >> c;
    int s = a + b + c;
    if(s >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
alphabet="abcdefghijklmnopqrstuvwxyz"
l=[]
a=1
sm=0
for i in range(15):
    a*=26
    sm+=a
    l.append(sm)

for i in range(len(l)):
    if n<=l[i]:
        cl=i
        break

if cl==0:
    print(alphabet[n-1])
    sys.exit()
ans=""
n-=l[cl-1]

#最後の１文字以外を決める
for i in range(cl):
    num=(n-1)//(26**(cl-i))
    ans=ans+alphabet[num]
    n-=(26**(cl-i))*num

if n!=0:
    ans=ans+alphabet[n-1]
else:
    ans=ans+"z"
print(ans)

Measured memory_bytes: 9152
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}
const int N=1e5+5;
vi v[N];
int dist[N],par[N];
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	string p;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        x--,y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    memset(dist,M2,sizeof(dist));
    priority_queue<pii>q;
    q.push({0,0});
    dist[0]=0;
    while(q.size())
    {
        auto x = q.top();
        q.pop();

        for(auto it:v[x.s])
        {
            if(dist[it]>dist[x.s]+1)
            {
                dist[it]=dist[x.s] + 1;
                par[it]=x.s;
                q.push({-dist[it],it});
            }
        }
    }
    bool flag=1;
    for(int i=0;i<n;i++)
    {
        if(dist[i]==M2)
        flag=0;
    }
    if(v[0].size()==0)
    flag=0;

    if(!flag)
    {
        cout<<"No";
    }
    else
    {
        par[0]=v[0][0];
        cout<<"Yes\n";
        for(int i=1;i<n;i++)
        cout<<par[i]+1<<'\n';
    }
    
    
return 0;
}

Measured memory_bytes: 15016
class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)

MOD = 10**9 + 7

N, K = map(int, input().split())
*A, = map(int, input().split())
A = sorted(A)
com = Combinatorics(N, MOD)
ans = 0
for i, a in enumerate(A):
    ans = (ans + a * com.binom(i, K-1)) % MOD
    ans = (ans - a * com.binom(N-i-1, K-1)) % MOD
print(ans)

Measured memory_bytes: 48076
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N, Y;
    cin >> N >> Y;
    ll max_x = Y / 10000;
    ll max_y = Y / 5000;
    ll max_z = Y / 1000;
    //cerr << max_x << ":" << max_y << ":" << max_z << endl;
    ll x, y, z;
    if(N < max_x || N > max_z)
    {
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    bool found = false;
    for(x=max_x;x>=0; x--)
    {
        ll res = Y - 10000*x;
        ll resN = N - x;
        //cerr << resN << ":" << res/1000 << ":" << res/5000 << endl;
        max_y = res / 5000;
        if(res / 1000 < resN && res / 5000 > resN) continue;
        for(y=max_y;y>=0;y--)
        {
            ll res2 = res-5000*y;
            ll resN2 = resN - y;
            if(resN2 == res2 / 1000)
            {
                z = resN2;
                found=true;
                break;
            }
        }
        if(found) break;
    }
    if(!found) cout << "-1 -1 -1" << endl;
    else cout << x << " " << y << " " << z << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        long ans = K;
        for (int i = 2; i <= N; i++) {
            ans *= K-1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

string ans = "";

void construct_LCS(string s, string t, const vector<vector<int>> &dp, int i, int j){
    if(i==0 || j==0){
        return;
    }
    if(s[i-1] == t[j-1]){
        construct_LCS(s,t,dp,i-1,j-1);
        ans += s[i-1];
    }else{
        if(dp[i-1][j]>=dp[i][j-1]){
            construct_LCS(s,t,dp,i-1,j);
        }else{
            construct_LCS(s,t,dp,i,j-1);
        }
    }
    return;
}

int main(){
    string s, t;
    cin >> s;
    cin >> t;

    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
    for(int i = 1; i <= s.size(); i++){
        for(int j = 1; j <= t.size(); j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1]+1);
            }else{
                dp[i][j] = max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1]);
            }
        }
    }
    construct_LCS(s,t,dp,(int)s.size(),(int)t.size());
    cout << ans << endl;

}


Measured memory_bytes: 65408
# include <iostream>
# include <cstdio>
# include <cmath>
# include <cstring>
using namespace std;
const double PI=3.1415926;
int X[100000005],Y[10000005];
int i,j,k;
int A=0,B=0,C=0;
int m,n,a,b,c,N;
int main()
{
	cin>>N;
	for(i=1;i<=N;i++)
	{
		scanf("%d",&X[i]);
		if(X[i]<=X[i-1])
		{
			A++;
			if(A>B)
			B=A;
		}
		else
		{
			A=0;
		}
		
	}
	cout<<B;
	return 0;
}

Measured memory_bytes: 2304
A = [0]*3
for i in range(0,3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
 
count = 0
while count < N:
    for i in range(0,3):
      for j in range(0,3):
        if b[count] == A[i][j]:
          A[i][j] = 0
    count += 1
            

sum_y = [0]*3                
for i in range(0,3):
  for j in range(0,3):
    sum_y[i] += A[i][j]#横
 
sum_t = [0]*3
for i in range(0,3):
  for j in range(0,3):
    sum_t[i] += A[j][i]
    
 
sum1 = A[0][0] + A[1][1] + A[2][2]
sum2 = A[0][2] + A[1][1] + A[0][2]
 
if sum_y[0] == 0:
    print("Yes")
elif sum_y[1] == 0:
    print("Yes")
elif sum_y[2] == 0:
    print("Yes")
elif sum_t[0] == 0:
    print("Yes") 
elif sum_t[1] == 0:
    print("Yes") 
elif sum_t[2] == 0:
    print("Yes") 
elif sum1 == 0:
  print("Yes")
elif sum2 == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int ans = 0;

            for (int i = 0; i < 3; i++) {
                if (s.charAt(i) == '1') {
                    ans++;
                }
            }

            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"debuglandınız\n";
ll int n,i,j,ar[500],dp[500][500],aral,pref[500];
void merge1(ll int x, ll int y){
	ll int gez;
	for(gez=x;gez<y;gez++){
		if(gez==x and gez+1==y)dp[x][y]=min(dp[x][y],ar[x]+ar[y]);
		else if (gez==x)dp[x][y]=min(dp[x][y],ar[x]+dp[gez+1][y]+pref[y]-pref[gez]);
		else if (gez+1==y)dp[x][y]=min(dp[x][y],dp[x][gez]+ar[y]+pref[gez]-pref[x-1]);
		else dp[x][y]=min(dp[x][y],dp[x][gez]+dp[gez+1][y]+pref[gez]-pref[x-1]+pref[y]-pref[gez]);
	}
}
void solve(){
	cin>>n;
	for(i=1;i<=n;i++)cin>>ar[i];
	for(i=1;i<=n;i++)pref[i]=pref[i-1]+ar[i];
	for(i=1;i<500;i++){
		for(j=1;j<500;j++){
			dp[i][j]=LLONG_MAX;
		}
	}
	for(i=1;i<=n;i++)dp[i][i]=ar[i];
	for(aral=2;aral<=n;aral++){
		for(i=1;i<=n-aral+1;i++){
			merge1(i,i+aral-1);
		}
	}
	/*for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[1][n];
}	
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	solve();
}

Measured memory_bytes: 2176
import java.util.*;
import java.util.regex.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int n = sc.nextInt();
        int[] t = new int[n+1];
        int[] x = new int[n+1];
        int[] y = new int[n+1];
        // 初期値
        t[0] = 0;
        x[0] = 0;
        y[0] = 0;
        // 入力値
        for (int i = 1; i <= n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        int dt, dist, diff;
        for (int i = 0; i < n; i++) {
            dt = t[i+1] - t[i];
            dist = Math.abs(x[i+1] - x[i]) + Math.abs(y[i+1] - y[i]);
            // if (dt < dist || (dist % 2 != dt % 2)) {
            //     // 出力
            //     System.out.println("No");
            //     return;
            // }
            diff = dist - dt;
            if (diff > 0 || (diff % 2 != 0)) {
                // 出力
                System.out.println("No");
                return;
            }        }

        // 出力
        System.out.println("Yes");
    }
}


Measured memory_bytes: 91304
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll A, B, AB;
  ll nA, nB;
  cin >> A >> B >> AB >> nA >> nB;
  ll res = 0;
  if (A + B > 2 * AB) {
    ll m = min(nA, nB);
    res = m * 2 * AB;
    nA -= m;
    nB -= m;
  }
  res += min(A, AB * 2) * nA + min(B, AB * 2) * nB;

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
S = gets.chomp
size = S.size
K = gets.chomp.to_i
s2 = Array.new(2*size)
for x in 0...size do
    s2[x] = S[x]
    s2[x+size] = S[x]
end

f = 1
for x in 1...size do
    if S[x] != S[x-1]
        f = 0
    end
end
if f == 1
    answer = size * K / 2
    puts answer
    exit
end

a1 = 0
i = 1
while i < size
    if S[i] == S[i-1]
        a1 += 1
        i += 1
    end
    i += 1
end

if K == 1
    puts a1
    exit
end

a2 = 0
i = 1
while i < 2 * size
    if s2[i] == s2[i-1]
        a2 += 1
        i += 1
    end
    i += 1
end

dif = a2 - a1
answer = a1 + dif * (K-1)
puts answer

Measured memory_bytes: 1788
x1, x2, x3, x4, x5 = map(int,input().split())
ans = 0
if x1==0:
  ans = 1
elif x2==0:
  ans = 2
elif x3==0:
  ans = 3
elif x4==0:
  ans = 4
else:
  ans = 5

print(ans)

Measured memory_bytes: 9112
#include <stdio.h>
 
int main(void)
{
    int num_int;
    scanf("%d", &num_int);
 
    if (num_int == 0) {
        printf("undefined\n");
    } else {
        int in_int_1;
        scanf("%d", &in_int_1);
        int min, max;
        long sum;
        min = max = sum = in_int_1;
 
        int i;
        for (i = 2; i <= num_int; i++) {
            int in_int_i;
            scanf("%d", &in_int_i);
 
            if (min > in_int_i) {
                min = in_int_i;
            }
 
            if (max < in_int_i) {
                max = in_int_i;
            }
 
            sum += in_int_i;
        }
 
        printf("%d %d %ld\n", min, max, sum);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define MAX 1000001
#define M 1000000009
#define ll long long
#define ld long double
using namespace std;

// int a, b;
// int r, lft, mod;

// int isPossible(int x) {
// 	int div = x/r;
// 	if (div+1>r+1) return 0;
// 	if (x>lft-ceil(double(x)/double(r))) return 0;
// 	return 1;
// }

// int bs(int l, int r) {
// 	if (l>r) return 0;
// 	int mid = (l+r)>>1;
// 	if (isPossible(mid)) {
// 		if (isPossible(mid+1)) return bs(mid+1, r);
// 		else return mid;
// 	}
// 	else return bs(l, mid-1);
// }

// int main() {
// 	cin >> a >> b;
// 	int flag = 0;
// 	if (a<b) {
// 		swap(a, b);
// 		flag = 1;
// 	}
// 	r = a/b;
// 	mod = a%b;
// 	if (mod) {
// 		lft = b-mod;
// 		int extra = bs(0, lft);
// 		cout << mod+extra << endl;
// 	}
// 	return 0;
// }

int main() {
	ll n;
	cin >> n;
	ll a[n];
	for (int i=0;i<n;i++) {
		cin >> a[i];
	}
	ll l, r;
	l = 2;
	r = 3;
	if (a[n-1]!=2) {
		cout << -1;
		return 0;
	}
	for (int i=n-2;i>=0;i--) {
		ll first;
		if (l%a[i]) first = (l/a[i]+1)*a[i];
		else first = l;
		ll last = (r/a[i])*a[i];
		if (first>r || last<l) {
			cout << -1;
			return 0;
		}
		l = first;
		r = last+a[i]-1;

		// cout << l << " " << r << endl;
	} 
	cout << l << " " << r;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int ans = 0;

		for (int i=1; i<=n; i++){
			int a = sc.nextInt();

			if (i % 2 == 1 && a % 2 == 1){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35684
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;

int main(){
	ios::sync_with_stdio(false);
	LL n,m;
	cin >> n >> m;
	cout << min(n % m,m - (n % m)) << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
table = [0 for _ in range(n-1)]
info = []
for _ in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    info.append([a, b])
info = sorted(info, key=lambda x:x[1])
for i, tap in enumerate(info):
    a, b = tap
    if i == 0:
        c = [b-1]
    elif a > c[-1]:
        c.append(b-1)
    else:
        pass
print(len(c))

Measured memory_bytes: 22920
import java.util.*;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();

		int[] cardCount = new int[100001];

		for (int i = 0; i < N; i++) {
			int ai = sc.nextInt();
			cardCount[ai]++;
		}

		int extra = 0;
		for (int i = 0; i < cardCount.length; i++) {
			if (cardCount[i] > 1) {
				extra += cardCount[i] - 1;
			}
		}

		if (extra % 2 == 0) {
			System.out.println(N - extra);
		} else {
			System.out.println(N - ((extra / 2) + 1) * 2);
		}

		sc.close();
	}

}


Measured memory_bytes: 50180
N = gets.to_i
tasks = []
N.times do
  tasks.push(gets.split(' ').map(&:to_i))
end

tasks.sort_by! do |_, y|
  y
end

sum = 0

(0...N).each do |idx|
  sum += tasks[idx][0]
  if sum > tasks[idx][1]
    print 'No'
    exit
  end
end

print 'Yes'


Measured memory_bytes: 22520
#include <stdio.h>

int main(void)
{
    int N;
    char s[101];
    int i;
    int R, B;
    
    
    
    R = B = 0;
    
    scanf("%d", &N);
    scanf("%s", s);
    
    
    for(i=0; i<N; i++)
    {
        if(s[i] == 'R')
            R++;
        else
            B++;
    }
    
    
    if(R > B)
        printf("Yes\n");
    else
        printf("No\n");
    
    
    //system("pause");
    
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F(i,a,b) for(ll i=a;i<=(b);++i)
#define dF(i,a,b) for(ll i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-7
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 10007;
const int maxn = 1e6+10;
const int N = 1e5+10;
const int E = 1e6+10; 

int n;
int a[maxn],b[maxn];
int ans = 0;

int main(){
	cin>>n;
	for(int a = 1;a<=n;a++){
		ans+=(n-1)/a;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3672
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r=sc.nextDouble();
        double pi=Math.PI;
        double area = pi*r*r;
        double length = 2*pi*r;
        System.out.printf("%f %f",area,length);
        sc.close();
    }
}


Measured memory_bytes: 28416
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g(100005);
vector<int> dp(100005, -1);

int rec(int s) {
  if (dp[s] != -1) return dp[s];

  int res = 0;
  for (int v: g[s]) {
    chmax(res, rec(v) + 1);
  }
  return dp[s] = res;
}

int main(void) {
  int n, m;
  cin >> n >> m;
  rep (i, m) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    g[x].pb(y);
  }

  rep (i, n) rec(i);

  int ans = 1;
  rep (i, n) chmax(ans, dp[i]);

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

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

const int N = 2e1 + 5;
int main() {
    string s, t;
    cin >> s >> t;
    int lens = s.length();
    int lent = t.length();
    int ans = 0x3f3f3f3f;
    for (int i = 0; i <= lens - lent; i++) {
        int changeWord = 0;
        for (int j = i; j < i + lent; j++) {
            if (s[j] != t[j - i]) changeWord++;
        }
        ans = min(ans, changeWord);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
main()
{
	long a;
	long b;
	long c;
	long k;
	
	scanf("%ld",&a);
	scanf("%ld",&b);
	scanf("%ld",&c);
	scanf("%ld",&k);
	
	long max=0;
	
	long w,r;
	
	long d=0;
	long e=0;
	
	if(k!=0)
	{
		if(a-k<=0)
		{
			while(a!=0)
			{
				max+=1;
				a--;
				d++;
			}
		}
		else
		{
			while(k!=0)
			{
				max+=1;
				k--;
			}
		}	
	}
	
	if((k-d)!=0)
	{
		if(b-(k-d)<=0)
		{
			while(b!=0)
			{
				max+=0;
				b--;
				e++;
			}
		}
		else
		{
			w=k-d;
			while(w!=0)
			{
				max+=0;
				w--;
			}
		}
	}
	
	if((k-d-e)!=0)
	{
		if(c-(k-d-e)>0)
		{
			r=k-d-e;
			while(r!=0)
			{
				max-=1;
				r--;
			}
			
		}
		else
		{
			while(c!=0)
			{
				max-=1;
				c--;
			}
		}
	}
	
	printf("%ld",max);
}

		

Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;
const string kk[2]={"(",")"};
const char k[2]={'(',')'};
bool solve(string str){
    int tmp=0;
    for(int i=0;i<str.size();i++){
        if(str[i]==k[0]){
            tmp++;
        }else{
            tmp--;
        }
        if(tmp<0) return false;
    }
    if(tmp==0){
        return true;
    }else{
        return false;
    }
}

int main(){
    int N;
    string str;
    cin>>N>>str;
    if(solve(str)){
        cout<<str<<endl;
        return 0;
    }
    for(int i=0;i<=N;i++){
        for(int j=i;j>=0;j--){//'('をj文字，')'を(N-j)文字
            string tmp=str;
            for(int x=0;x<j;x++){
                tmp=kk[0]+tmp;
            }
            for(int x=j;x<i;x++){
                tmp=tmp+kk[1];
            }
            if(solve(tmp)){
                cout<<tmp<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
a1,a2,b1,b2 = map(int,input().split())
a1,a2,b1,b2
count = 0
if a1 <= b1:
    for i in range(a2+1):       
        if i > b1 and i <= b2:
            count += 1
elif b1 <= a1:
    for i in range(b2+1):
        if i > a1 and i <= a2:
            count += 1
print(count)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int N=0, now=0, ans=0;
  cin >> N;
  int H[N];
  rep(i, N){
    cin >> H[i];
  }
  rep(i, N-1){
    if (H[i] >= H[i+1]){
      now++;
      ans = max(ans, now);
    }
    else now = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4016
N,M = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
        
    def find_root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
        
    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
                
    def isSameGroup(self, x, y):
        return self.find_root(x) == self.find_root(y)
    
    def count(self, x):
        return -self.root[self.find_root(x)]

uf = UnionFind(N)
for _ in range(M):
    x,y,z = map(int, input().split())
    uf.unite(x, y)
    
L = [0]*(N+1)
for i in range(1, N+1):
    r = uf.find_root(i)
    if L[r] == 0:
        L[r] = 1
        
print(sum(L))

Measured memory_bytes: 8516
import sys

h, w = map(int, raw_input().split())
s = [raw_input() for _ in xrange(h)]

dir = [(-1, 0), (1, 0), (0, -1), (0, 1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            flag = False
            for d in dir:
                x = j + d[0]
                y = i + d[1]
                if 0 <= x < w and 0 <= y < h and s[y][x] == '#':
                    flag = True
            if not flag:
                print 'No'
                sys.exit()
print 'Yes'


Measured memory_bytes: 2568
#include <stdio.h>

int main(void){
    long int N, M;
    scanf("%ld", &N);
    scanf("%ld", &M);

    if(M > 2 && N > 2){
        printf("%ld\n", (M - 2) * (N - 2));
    }else if(M == 1 && N == 1){
        printf("1\n");
    }else if(M == 1 && N > 2){
        printf("%ld\n", N - 2);
    }else if(N == 1 && M > 2){
        printf("%ld\n", M - 2);
    }else{
        printf("0\n");
    }
    return 0;
}


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

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

int main(){
	int n, a, b;
	vector<int> v;
	
	cin>>n;
	cout<<n*n;
	//cin>>n; v.resize(n); rep(i,n) cin>>v[i];
	
	
	
	
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,n,k,t,a[200001]={0},ans=0;
	cin>>n>>k;
	vector <int> g;
	for (i=0;i<n;i++){
		cin>>t;
		a[t]++;
	}
	for (i=1;i<200001;i++){
		if (a[i]>0){
			g.push_back(a[i]);
		}
	}
	sort(g.begin(),g.end());
	if (g.size()>k){
		for (i=g.size()-k-1;i>=0;i--){
			ans+=g[i];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2168
h,w,K = map(int, input().split())
s = [input() for i in range(h)]

ans = float('inf')

for i in range(2**(h-1)):
    a = format(i,'b').zfill(h-1)
    choco = [[int(x) for x in s[0]]]
    for k in range(1,h):
        if a[k-1]=='1':
            choco.append([0 for x in range(w)])
        for j in range(w):
            if s[k][j]=='1':
                choco[-1][j]+=1
    b = 0
    c = [0 for x in range(len(choco))]
    ok = 1
    for j in range(w):
        for k in range(len(choco)):
            if choco[k][j]>K:
                ok = 0
                break
            c[k]+=choco[k][j]
        if max(c)>K:
            b+=1
            c = [choco[x][j] for x in range(len(choco))]
    if ok:
        ans = min(b+a.count('1'),ans)
print(ans)


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

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

int main()
{
  ll A, B;
  ll strange[13] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1};
  cin >> A >> B;
  ll ai = 0;
  rep(i,0,13){
    if (strange[i] == A)
    {
      ai = i;
    }
  }
  rep(i,0,13){
    if (strange[i] == B)
    {
      if (ai > i)
      {
        cout << "Alice" << endl;
      }else if (ai < i){
        cout << "Bob" << endl;
      }else{
        cout << "Draw" << endl;
      }
    }
  }
  return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int a = 0;
	ll ans = 1;
	REP(i, n) {
		if (i == 0) {
			if (s[i] == t[i])ans = 3;
			else {
				ans = 6;
				a = 1;
				++i;
			}
		}
		else {
			if (s[i] == t[i]) {
				if (a == 0) {
					ans *= 2;
					ans %= MOD;
				}
				else {
					
					a = 0;
				}
			}
			else {
				if (a == 0) {
					ans *= 2;
					ans %= MOD;
					a = 1;
				}
				else {
					ans *= 3;
					ans %= MOD;
				}
				i++;
			}
		}
	}
	cout << ans << endl;
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  string s;
  cin >> s;
  repi(3) cout << (s[i] == '1' ? '9' : s[i] == '9' ? '1' : s[i]);
  cout << endl;
}


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


int main()
{
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if ((v - w) * t >= abs(a - b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x; cin>>x;
  int ans=0;
  string s;
  for(int i=0;i<x.size()-1;++i)
    s+=x[i];
  for(int i=1;i<s.size();++i){
    string t,r;
    for(int j=0;j<i;++j)
      t+=s[j];
    for(int j=i;j<i+i;++j)
      r+=s[j];
    if(t==r) ans=max(ans,(int)(t.size())*2);
  }
  cout<<ans<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

// dp[i][j][k]
// i桁目まで決めて、
// j個のnon0を使って。
// k:0そこまでの桁はnと一致
// k:1そこまでの桁はn以下

int main() {
  string s;
  ll k, n;
  cin >> s >> k;
  n = s.size();
  ll dp[101][4][2] = {};
  dp[0][0][0] = 1;

  rep(i, n) rep(j, 4) rep(l, 2) {
    ll nd = s[i] - '0';
    rep(d, 10) {
      ll ni = i + 1, nj = j, nl = l;
      if (d > 0) nj++;
      if (nj > k) continue;
      if (l == 0) {
        if (d < nd) nl = 1;
        if (d > nd) continue;
      }
      dp[ni][nj][nl] += dp[i][j][l];
    }
  }

  cout << dp[n][k][0] + dp[n][k][1] << endl;
  return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < m; i++){
        cin >> a[i];
    }
    // n - study = ans

    int s = 0;
    for(int i = 0; i < m;i++)
        s += a[i];
        if (s > n)
        {
            cout << "-1" << endl;
        }
        else
        {
            cout << n - s << endl;
        }
    return 0;
}

Measured memory_bytes: 7204
#include <bits/stdc++.h> 
using namespace std; 
int main(){ 
  int a,b,c,d,K;
  cin >>a>>b>>c>>d>>K;
  int M = c-a;
  int N = d-b;
  int i;
  if(N>=0){
  i = 60*M + N;
  }
  else if(N<0){
  i = 60*M + N; 
  }
  if(i-K>=0){
  cout << i-K << endl;
  }
  else if(i-K<0){
  cout << "0" << endl;
  }
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

int main(){
	string str;
	cin >> str;

	if (str.length() == 2){
		cout << str << endl;
	}

	else if (str.length() == 3){
		reverse(str.begin(), str.end());
		cout << str << endl;
	}
}


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

#define mp make_pair
#define pb push_back
#define p push

#define FOR(a, c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) (1e5+5)

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector <vector<int>> vvi;
typedef vector<long long> vl;
typedef vector <pair<int, int>> vpi;
typedef vector <pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <vi> graph;

int k = 5;

int main (){
    IOS
    ll n ;
    cin >>n;
    if(n&1){
        cout <<0;
        return 0;
    }
    ll k  = n/2;
    ll res =0 ;
    while(k >0){
        k /=5;
        res+=k;
    }
    cout << res;



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2000000
using namespace std;
typedef long long ll;
int main()
{
//    freopen("in.txt","r",stdin);


    ll ans=0LL;
    string s,t;
    cin>>s>>t;
    ll n=s.size();
    for(ll i=0;i<n;i++)
    {
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1e+9
#define MAX_V 100000
using vi = vector<int>;
struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
//vector<edge> G[MAX_V];
//vector<int> G[MAX_V];
int d[MAX_V];
int dd[MAX_V];
/*
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
void dijkstra2(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(dd, dd+V, INF);
    dd[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dd[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (dd[e.to] > dd[v] + e.cost) {
                dd[e.to] = dd[v] + e.cost;
                que.push(P(dd[e.to], e.to));
            }
        }
    }
}*/
void dfs(int i, int p, const vector<vector <int>> &g,  vector<int> &dis) {
  for (auto&& j : g[i]) {
    if (j != p) {
      dis[j] = 1 + dis[i];
      dfs(j, i, g, dis);
    }
  }
}

int main() {
    int N,u,v;
    cin >> N >> u >> v;
    //V = N+1;
    vector<vector<int>> G(N);
    for (int i=0; i<N-1; ++i) {
        int a, b;
        cin >> a >> b;
        //edge e = {a, 1};
        //edge e2 = {b,1};
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);

    }
    vector<vector<int>> dis(2, vi(N));
 
    dfs(u-1, -1, G, dis[0]);
    dfs(v-1, -1, G, dis[1]);
    if(u == v){
        cout << 0 << endl;
        return 0;
    }
    /*
    edge e =  {v,0};
    edge e2 = {u,0};
    G[0].push_back(e);
    G[0].push_back(e2);
    dijkstra(v);
    dijkstra2(u);
    */

    int maximum = 0;
    for (int i=0; i<N; ++i) {
        //cout << "iiiiiiiiiiiiii:"<< d[i] <<" aaa:"<<dd[i]<< endl;
        //if(d[i] != INF){
            //d[]が追いかけるほう、dd[]が追いかけられる方
            //cout << "vから" << i << "までのコスト: " << d[i] << endl;
            //cout << "iiiiiiiiiiiiii:"<< d[i] <<" aaa:"<<dd[i]<< endl;
            if(dis[1][i] > dis[0][i]){
                if(maximum < dis[1][i]){
                    maximum = dis[1][i];
                }
            }
        //}
    }
    cout << maximum-1 << endl;
}



Measured memory_bytes: 12920
s = input()
n = len(s)
count = 0
data = []
for i in range(n):
    data.append(int(s[i]))
for  i in range(n -1):
    if data[i] == data[i + 1]:
        data[i + 1] = (data[i + 1] + 1) % 2
        count += 1
print(count)

Measured memory_bytes: 3956
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a<b) {
        	System.out.println("a < b");
        } else if (a > b) {
        	System.out.println("a > b");
        } else {
        	System.out.println("a == b");
        }
        
    }
}


Measured memory_bytes: 26388