akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b == c + d)
    {
        cout << "Balanced" << endl;
    }
    else if (a + b > c + d)
    {
        cout << "Left" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<ll> dp0(n+1);  /* dp0[i+1] :  aおよびbの上からi桁目(iは0-index)までを確定させ、
                                         その時点ではまだa+bがs未満になるかわかっていない
                                         (a, b)の組の個数 */
    
    vector<ll> dp1(n+1);  /* dp1[i+1] :  aおよびbの上からi桁目(iは0-index)までを確定させ、
                                         その時点で既にa+bがs未満であることがわかっている
                                         (a, b)の組の個数 */

    dp0[0] = 1;
    rep(i, n) {

        // (a_i, b_i) = (0, 0) のとき
        if(s[i] == '0') {
            dp0[i+1] += dp0[i];
            dp1[i+1] += dp1[i];
        } 
        else if(s[i] == '1') {
            dp1[i+1] += (dp0[i] + dp1[i]);
        }

        // (a_i, b_i) = (1, 0), (0, 1) のとき
        if(s[i] == '0') {
            dp1[i+1] += 2*dp1[i];
        } 
        else if(s[i] == '1') {
            dp0[i+1] += 2*dp0[i];
            dp1[i+1] += 2*dp1[i];
        }

        dp0[i+1] %= mod;
        dp1[i+1] %= mod;
    }

    cout << (dp0[n] + dp1[n])%mod << endl;
    return 0;
}

Measured memory_bytes: 2048
N=int(input())
A=[list(map(int,input().split()))for i in range(2)]
dp=[[-1]*N for i in range(2)]
dp[0][0]=A[0][0]
for i in range(2):
  for j in range(N):
    if i == 0:
      if j==0:
        continue
      else:
        dp[i][j]=dp[i][j-1]+A[i][j]
    else:
      if j == 0:
        dp[i][j]=dp[i-1][j]+A[i][j]
      else:
        dp[i][j]=A[i][j]+max(dp[i][j-1],dp[i-1][j])
print(dp[1][N-1])

Measured memory_bytes: 3064
N,M = map(int,raw_input().split())

array = [map(int,raw_input().split()) for i in range(N)]

v = [[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]

ans = 0

for i in range(8):
    tmp = []
    for j in range(N):
        tmp.append(array[j][0]*v[i][0]+array[j][1]*v[i][1]+array[j][2]*v[i][2])
    tmp.sort()
    ans = max(ans,sum(tmp[N-M:]))

print ans

Measured memory_bytes: 2820
import java.util.Scanner;

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

        int[][] table = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                table[i][j] = sc.nextInt();
            }
        }
        int sum=0;
        for (int i = 0; i < m; i++) {
        if(table[0][i]>table[1][i])
        	sum+=table[0][i]-table[1][i];
        }
        System.out.println(sum);
		sc.close();
    }
}

Measured memory_bytes: 23764
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
xy = [0] * n

xy_plus_max = -10 ** 10
xy_plus_min = 10 ** 10
xy_minus_max = -10 ** 10
xy_minus_min = 10 ** 10
for i in range(n):
    x, y = map(int, input().split())
    xy_plus_max = max(xy_plus_max, x + y)
    xy_plus_min = min(xy_plus_min, x + y)
    xy_minus_max = max(xy_minus_max, x - y)
    xy_minus_min = min(xy_minus_min, x - y)

print(max(xy_plus_max - xy_plus_min, xy_minus_max - xy_minus_min))


Measured memory_bytes: 69764
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, k) = (v[0], v[1]);
    let a = read_vec::<usize>();
    let big_int = 1000_000_000 + 7;

    let mut dp = vec![vec![0u64; k + 1]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        let mut temp = 0u64;
        for j in 0..k + 1 {
            temp += dp[i][j];
            temp %= big_int;
            dp[i + 1][j] = temp;
            if j >= a[i] {
                temp = temp + big_int - dp[i][j - a[i]];
                temp %= big_int;
            }
        }
    }
    println!("{:?}", dp[n][k] % big_int);
}


Measured memory_bytes: 106748
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define Mod 1000000007

int main(void){
	long i;
	long long ans=1;
	
	long n,m;
	scanf("%ld%ld",&n,&m);
	
	long a[m+2];
	a[0]=-1;
	a[m+1]=n+1;
	for(i=1;i<=m;i++){
		scanf("%ld",&a[i]);
	}
	
	long d[m+1];
	for(i=0;i<=m;i++){
		d[i]=a[i+1]-a[i]-1;
	}
	
	long fib[n+1];
	fib[0]=0,fib[1]=1,fib[2]=1,fib[3]=2;
	for(i=4;i<=n+1;i++){
		fib[i]=(fib[i-1]+fib[i-2])%Mod;
	}
	
	for(i=0;i<=m;i++){
		ans=(ans*fib[d[i]])%Mod;
	}
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 2560
import itertools


n = int(input())
h = [int(i) for i in input().split()]

d = [0] + [1 if h[i] <= h[i-1] else 0 for i in range(1, n)]
ans = 0
for key, group in itertools.groupby(d):
    count = 0
    if key == 0:
        continue
    for g in group:
        count += g
    ans = max(ans, count)
print(ans)

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

int main()
{
  string N;
  cin >> N;
  rep(i, N.size()) {
    if (N.at(i) == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

Pint f(int n) {
  int l = n%10;
  int t = 0;
  while(n) {
    t = n%10;
    n/=10;
  }
  return Pint(t,l);
}

int main(int argc, char const* argv[])
{
  int n;
  cin>>n;

  map<Pint,ll> m;
  REP1(i,n+1) {
    m[f(i)]++;
  }

  ll ans = 0;
  REP1(i,n+1) {
    Pint p = f(i);
    Pint invp = Pint(p.second, p.first);
    ans += m[invp];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int N=55;
const int mod=1e9+7;
ll dp[N][N*N];
int main()
{
    int n,a;
    cin>>n>>a;
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        for(int j=i-1;j>=0;j--)
            for(int k=0;k<=N*j;k++)
                dp[j+1][k+x]+=dp[j][k];
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans+=dp[i][i*a];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll N;
	cin >> N;
	struct P {
		double x;
		double y;
		P operator+(P rhs) {
			return {x+rhs.x, y+rhs.y};
		}
		P operator-(P rhs) {
			return {x-rhs.x, y-rhs.y};
		}
		P operator-() {
			return {-x, -y};
		}
		double operator*(P rhs) {
			return x*rhs.x + y*rhs.y;
		}
		P operator*(double k) {
			return {x*k, y*k};
		}
		P operator/(double k) {
			return {x/k, y/k};
		}
		double len_sq() {
			return (*this)*(*this);
		}
		double len() {
			return sqrt(len_sq());
		}
	};
	vector<P> pts(N);
	rep(i,0,N) {
		P p;
		cin >> p.x >> p.y;
		pts[i] = p;
	}
	double EPS = 1.0e-7;
	auto enclose = [&pts, N, EPS](P c, double r) -> bool {
		rep(i,0,N) {
			if ((c - pts[i]).len_sq() > (r + EPS) * (r + EPS)) {
				return false;
			}
		}
		return true;
	};
	double rad = numeric_limits<double>::max();
	rep(i,0,N) {
		rep(j,i+1,N) {
			P c = (pts[i] + pts[j]) / 2;
			double r = (pts[i] - pts[j]).len() / 2;
			if (enclose(c, r)) {
				rad = min(rad, r);
			}
		}
	}
	rep(i,0,N) {
		rep(j,i+1,N) {
			rep(k,j+1,N) {
				double a = (pts[i]-pts[j]).x;
				double b = (pts[i]-pts[j]).y;
				double c = (pts[i]-pts[k]).x;
				double d = (pts[i]-pts[k]).y;
				double e = (pts[i].len_sq() - pts[j].len_sq()) / 2;
				double f = (pts[i].len_sq() - pts[k].len_sq()) / 2;
				double D = a*d-b*c;
				if (D == 0.0) {
					continue;
				}
				double x = (d*e-b*f)/D;
				double y = (-c*e+a*f)/D;
				P cen = {x, y};
				double r = (cen - pts[i]).len();
				if (enclose(cen, r)) {
					rad = min(rad, r);
				}
			}
		}
	}
	cout << fixed << setprecision(10) << rad << endl;
}


Measured memory_bytes: 888
#include <stdio.h>
int func(int);
int main (){
    int n;
    scanf("%d",&n);
    printf("%d\n",func(n));
    return 0;
}
int func(int n){
    int f[45],i;
    f[0]=1;
    f[1]=1;
    for(i=2;i<=n;i++){
        f[i]=f[i-1]+f[i-2];
    }
    return f[n];
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n,k;cin>>n>>k;
    vi dp(k+1);
    dp[0]=1;
    rep(i,n){
        vi ndp(k+1);
        ll a;cin>>a;a++;
        ll sum=0;
        rep(j,a){
            if(k-j<0)break;
            sum=(sum+dp[k-j])%mod;
        }
        for(int j=k;j>=0;j--){
            ndp[j]=sum;
            sum=(sum-dp[j]+mod)%mod;
            if(j-a>=0)sum=(sum+dp[j-a])%mod;
        }
        dp=ndp;
    }
    out(dp[k]);
}

Measured memory_bytes: 4840
N,Y=map(int,input().split())
answer=-1,-1,-1
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z and 10000*x+5000*y+1000*z==Y:
            answer=x,y,z
            break
        
    
print(*answer)

Measured memory_bytes: 3060
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

bool query(int u, int v)
{
	cout<<"? "<<u<<' '<<v<<'\n';
	fflush(stdout);
	char c; cin>>c;
	return (c=='Y'?1:0);
}

bool good[4111];

int main()
{
	int a,b; cin>>a>>b;
	if(b>=a){cout<<"Impossible\n"; fflush(stdout); return 0;}
	stack<int> s;
	s.push(0);
	for(int i=1;i<a+b;i++)
	{
		if(s.empty())
		{
			s.push(i); continue;
		}
		int tmp=query(s.top(),i);
		if(!tmp)
		{
			s.pop();
		}
		else
		{
			s.push(i);
		}
	}
	for(int i=0;i<a+b;i++)
	{
		good[i]=query(s.top(),i);
	}
	cout<<"! ";
	for(int i=0;i<a+b;i++) cout<<good[i];
	cout<<'\n'; fflush(stdout);
}


Measured memory_bytes: 724
#include<iostream>
using namespace std;
int main(){
	int n,i,j,k,l,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	string s;
	cin>>s;
	s=" "+s;
	if(c<d){
		for(i=a;i<=min(d-1,n-1);i++){
			if(s[i]==s[i+1]&&s[i]=='#'){
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes";
	}
	else{
		for(i=a;i<=min(c-1,n-1);i++){
			if(s[i]==s[i+1]&&s[i]=='#'){
				cout<<"No";
				return 0;
			}
		}
		for(i=b-1;i<=min(d-1,n-2);i++){
			if(s[i]==s[i+1]&&s[i+1]==s[i+2]&&s[i]=='.'){
				cout<<"Yes";
				return 0;
			}
		}
		cout<<"No";
	}
}

Measured memory_bytes: 772
N, H = map(int,input().split())
L = []
maxi = 0
for _ in range(N):
    a,b = map(int,input().split())
    maxi = max(maxi, a)
    L.append(b)
 
#L = sorted([x for x in L if x > maxi])[::-1]
L = sorted(filter(lambda x:x>maxi,L))[::-1]
throw = 0
for i in range(len(L)):
    throw += L[i]
    if throw >= H:
        print(i + 1)
        quit()
from math import ceil
print(ceil((H - throw) / maxi) + len(L))
    



Measured memory_bytes: 8676
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int[] arr=str.Select(int.Parse).ToArray();
      Array.Sort(arr);
      int ans=(10*arr[2])+arr[1]+arr[0];
      Console.WriteLine(ans);
    }
    
  }

}


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


public class Main {
  public static void main(String[] args) {
    InputReader_INTXOR ir = new InputReader_INTXOR(System.in);
    int n = ir.readInt();
    int m = ir.readInt();
    int a[] = new int[m + 1];
    int sum = 0;
    for (int i = 0; i < m; i++) {
      a[i] = ir.readInt();
      sum += a[i];
    }
    int rem = n - sum;
    System.out.println(Math.max(rem, -1));
    System.out.flush();
  }
}
  class InputReader_INTXOR {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader_INTXOR(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1)
        throw new InputMismatchException();
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0)
          return -1;
      }
      return buf[curChar++];
    }

    public final int readInt() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long readLong() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public String readString() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = read();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
        return filter.isSpaceChar(c);
      return isWhitespace(c);
    }

    public double readDouble() {
      return Double.parseDouble(readString());
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next() {
      return readString();
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }


Measured memory_bytes: 26048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define ri register int
#define For(i,a,b) for(ri i=(a);i<=(b);++i)
#define DFor(i,a,b) for(ri i=(a);i>=(b);--i)
template<class T>inline T Max(register T a,register T b){return a>b?a:b;}
template<class T>inline T Min(register T a,register T b){return a<b?a:b;}
const int MAXN=100005;
int n,cnt,flag,t,tot;
int fa[MAXN],x[MAXN],y[MAXN],a[MAXN],b[MAXN];
int ct[MAXN];
struct node{int data,id;}c[MAXN<<1];
template<class T>inline void read(T&x){
  char ch=getchar();x=0;
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
}
int getfa(int x){return fa[x]==x?x:fa[x]=getfa(fa[x]);}
inline void merge(int u,int v){
	int fu=getfa(u),fv=getfa(v);
	fa[fu]=fv;
}
inline bool cmp(const node n1,const node n2){return n1.data<n2.data;}
inline void unq(){
	sort(c+1,c+1+tot,cmp);
	c[0].data=-1;
	//For(i,1,n+1)printf("%d ",b[i]);puts("");
	For(i,1,tot){
		if(c[i].data!=c[i-1].data)++t;
		int x=c[i].id;
		if(x<=n+1)a[x]=t;
		else b[x-n-1]=t;
	}
	For(i,1,n+1)x[i]=a[i],y[i]=b[i];
	sort(x+1,x+2+n),sort(y+1,y+2+n);
	For(i,1,n)if(x[i]!=y[i])flag=1;
	if(flag)return;
	For(i,1,t)fa[i]=i;
	For(i,1,n){
		if(a[i]!=b[i])merge(b[i],a[i]),++cnt,++ct[a[i]];
	}
	if(a[n+1]!=b[n+1])merge(b[n+1],a[n+1]),++ct[a[n+1]];
}
int main(){
	read(n);
	For(i,1,n)read(a[i]),a[n+1]^=a[i],c[++tot]=(node){a[i],i};
	For(i,1,n)read(b[i]),b[n+1]^=b[i],c[++tot]=(node){b[i],i+n+1};
	c[++tot]=(node){a[n+1],n+1},c[++tot]=(node){b[n+1],2*(n+1)};
	unq();
	//printf("ans=%d\n",cnt);
	For(i,1,t)if(fa[i]==i&&ct[i])++cnt;
	//For(i,1,t)printf("%d ",fa[i]);puts("");
	if(a[n+1]==b[n+1]&&!ct[a[n+1]])++cnt;
	//printf("ans=%d\n",cnt);
	//For(i,1,t)printf("%d ",fa[i]);puts("");
	//For(i,1,t)printf("%d ",fa[i]);
	//printf("%d:%d %d:%d\n",a[n+1],ct[a[n+1]],b[n+1],ct[b[n+1]]);
	cnt--;
	if(flag)printf("-1\n");
	else {
		printf("%d\n",cnt);
	}
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n;cin>>n;
  string str[n];
  map<string,int>m;
  vector<ll>sum(n+1,0);

  for(int i=1;i<n;i++){
    sum[i]=sum[i-1]+i;
  }

  rep(i,n){
    cin>>str[i];
    sort(str[i].begin(),str[i].end());
    m[str[i]]++;
  }
  ll count=0;
  for(int i=0;i<n;i++){
    if(m[str[i]]>1)count+=sum[m[str[i]]-1];
    m[str[i]]=0;
  }
  out(count);

  return 0;
}


Measured memory_bytes: 18944
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a + b == 15) {
            System.out.println("+");
        } else if (a * b == 15) {
            System.out.println("*");
        } else {
            System.out.println("x");
        }
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21076
N=int(input())
a=list(map(int,input().split()))
b=[0]*(N+1)#箱

ans=[]
for i in range(N,0,-1):
    bit=0
    for j in range(N//i):
        bit+=b[i+j*i]
    bit%=2
    if bit!=a[i-1]:
        b[i]=1
        ans.append(i)

print(sum(b))
print(' '.join(map(str, ans)))

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

int main(){
  int ans = 0;
  int n;
  cin >> n;
  while(n != 0){
    int m;
    cin >> m;
    string s;
    cin >> s;
    string see = "I";
    for(int i = 0; i < n; i++){
      string temp = "OI";

      see = see+temp;
    }
    int ans =  0;
    string sn = s.substr( 0 , n*2);
    for(int i = 0; i < m - n*2 ; i ++){
      sn = s.substr(i , n*2+1);
      if(sn == see)ans++;
    }
    
  cout << ans << endl;
    cin >> n;
  }


 
}



Measured memory_bytes: 3924
N=input()
list=[int(x) for x in input().split()]
i=0
kei=0
k=0
while(i!=len(list)-1):
    if(list[i]>list[i+1]):
        kei+=list[i]-list[i+1]
        list[i+1]=list[i]
    i+=1
print(kei)

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int a = stdIn.nextInt();
		if(x<a) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}

}


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

int main(){
    string N;
    cin >> N;
    string C;

    bool check = true;
    for (int i = 0; i < N.size()/2; i++)
    {
        if(N.at(i) != N.at(N.size()-1-i)){
            check = false;
        }      
    }
    
    C = N.substr(0,(N.size()-1)/2);
    for (int i = 0; i < C.size()/2; i++)
    {
        if(C.at(i) != C.at(C.size()-1-i)){
            check = false;
        }      
    }
    
    C = N.substr((N.size()+3)/2-1);
    for (int i = 0; i < C.size()/2; i++)
    {
        if(C.at(i) != C.at(C.size()-1-i)){
            check = false;
        }        
    }   

    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;   
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int N, a[101];
int main() {
  scanf("%d", &N);
  int mx = -101, mn = 101;
  for(int i = 1; i <= N; ++i) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
    mn = min(mn, a[i]);
  }
  int ans = 1e9;
  for(int i = mn; i <= mx; ++i) {
    int sum = 0;
    for(int j = 1; j <= N; ++j) {
      sum += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans, sum);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main implements Runnable {

    public static String reverse(String s)
    {
        return new StringBuilder(s).reverse().toString();
    }
    public static boolean isPal(String s){
       String s1 = reverse(s);
       if (s.equals(s1)){
           return true;
       }
       return false;
    }
    public void solve() throws Exception {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
           String s = sc.nextLine();
           int len = s.length();
           String s1 = s.substring(0,((len-1)/2));
           String s2 = s.substring(((len+1)/2));

           boolean flag1 = isPal(s);
           boolean flag2 = isPal(s1);
           boolean flag3 = isPal(s2);

        if (flag1 && flag2 && flag3){
            out.println("Yes");
        }else
            out.println("No");
    }


    //main function//
    public static PrintWriter out;

    public static void main(String[] args) throws Exception {
        new Thread(null, new Main(), "", 1 << 26).start();
    }

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }


        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        boolean hasNextInt() {
            return true;
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

    public void run() {
        try {
            solve();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        } finally {
            out.close();
        }
    }
}

Measured memory_bytes: 23508
tmp = input().split()
N = int(tmp[0])
K = int(tmp[1])
tmp = input().split()
R = int(tmp[0])
S = int(tmp[1])
P = int(tmp[2])
T = input()

history = []
ans = 0
for i in range(N):
    if not (i > K-1):
        if T[i] == "r":
            ans += P
            history.append([T[i], True])
        elif T[i] == "s":
            ans += R
            history.append([T[i], True])
        else:
            ans += S
            history.append([T[i], True])
        # print(i)
    else:
        if T[i] != T[i-K] or (T[i] == T[i-K] and history[i-K][1] == False):
            if T[i] == "r":
                ans += P
                history.append([T[i], True])
            elif T[i] == "s":
                ans += R
                history.append([T[i], True])
            else:
                ans += S
                history.append([T[i], True])
            # print(i)
        else:
            history.append([T[i], False])
    # print(history)
print(ans)

Measured memory_bytes: 13300
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, Q;
vector<int> g[212345];
int ans[212345], add[212345];

void dfs(int u, int prev) {
	ans[u] = add[u];
	REP(i, g[u].size()) {
		int v = g[u][i];
		if (v == prev) continue;
		add[v] += add[u];
		dfs(v, u);
	}
}

int main() {
	cin >> N >> Q;
	REP(i, N - 1) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	REP(i, Q) {
		int p, x;
		scanf("%d %d", &p, &x);
		add[p - 1] += x;
	}
	
	dfs(0, -1);
	
	REP(i, N) printf("%d%c", ans[i], i == N - 1 ? '\n' : ' ');
	
	return 0;
}


Measured memory_bytes: 27648
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 19 + 7
EPS = 10 ** -10

H, W, K = MAP()
grid = list2d(H+1, W+1, 0)
for i in range(K):
    h, w, v = MAP()
    grid[h][w] = v

dp0 = list2d(H+1, W+1, -INF)
dp1 = list2d(H+1, W+1, -INF)
dp2 = list2d(H+1, W+1, -INF)
dp3 = list2d(H+1, W+1, -INF)
dp0[0][1] = dp0[1][0] = 0
for h in range(1, H+1):
    for w in range(1, W+1):
        dp0[h][w] = max(dp0[h][w-1], dp0[h-1][w], dp0[h-1][w], dp1[h-1][w],  dp2[h-1][w], dp3[h-1][w])
        dp1[h][w] = dp1[h][w-1]
        dp2[h][w] = dp2[h][w-1]
        dp3[h][w] = dp3[h][w-1]
        if grid[h][w]:
            dp1[h][w] = max(dp1[h][w], max(dp0[h][w-1], dp0[h-1][w], dp1[h-1][w], dp2[h-1][w], dp3[h-1][w]) + grid[h][w])
            dp2[h][w] = max(dp2[h][w], dp1[h][w-1] + grid[h][w])
            dp3[h][w] = max(dp3[h][w], dp2[h][w-1] + grid[h][w])
ans = max(dp0[H][W], dp1[H][W], dp2[H][W], dp3[H][W])
print(ans)


Measured memory_bytes: 425080
#include<bits/stdc++.h>
using namespace std;
#define		ll		         long long int
#define		N		         100005
#define		ff 	             first
#define		ss		         second


ll wt[N],val[N];
ll dp[105][100005];
ll solve(ll w,ll n)
{
    if(n==0 || w==0)
        return 0;

    if(dp[n][w]!=-1)
        return dp[n][w];

    if(wt[n-1]>w)
        return solve(w,n-1);

    else
    {
        ll d=max( ( val[n-1] + solve(w-wt[n-1],n-1) ), solve(w,n-1));
        dp[n][w]=d;
        return d;
    }
}

int main()
{
    ll n,i,w;
    memset(dp,-1,sizeof dp);
    cin>>n>>w;
    for(i=0;i<n;i++)
        cin>>wt[i]>>val[i];

    ll d=solve(w,n);
    cout<<d<<endl;
	return 0;
}




Measured memory_bytes: 82432
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e6 + 5;

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rw", stdin);
#endif
	char c;
	cin >> c;
	if(c >= 'a' && c <= 'z') {
		cout << "a";
	} else {
		cout << "A";
	}
	return 0;
}


Measured memory_bytes: 3628
from collections import Counter

N, M = map(int, input().split())
*X, = map(int, input().split())
*l, = map(lambda x:x%M, X)
c1 = Counter(l)
c2 = Counter(X)
c3 = Counter()

for i, j in c2.items():
    c3[i%M] += j//2

ans = c1[0]//2

for i in range(1, M):
    if i>M-i:break
    elif i==M-i:
        ans += c1[i]//2
    else:
        ans += min(c1[i], c1[M-i])        
        if c1[i] > c1[M-i]:
            v2 = c1[i]-c1[M-i]
            ans += min(v2//2, c3[i])
        else:
            v2 = c1[M-i]-c1[i]
            ans += min(v2//2, c3[M-i])

print(ans)


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

int main() {
    int n;
    cin >> n;
    if(n <= 599) cout << 8 << endl;
    else if (n <= 799) cout << 7 << endl;
    else if (n <= 999) cout << 6 << endl;
    else if(n <= 1199) cout << 5 << endl;
    else if(n <= 1399) cout << 4 << endl;
    else if (n <= 1599) cout << 3 << endl;
    else if(n <= 1799) cout << 2 << endl;
    else if(n <= 1999) cout << 1 <<endl;
    return 0;
}


Measured memory_bytes: 3628
use std::collections::HashSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn dfs(now: usize, pre: usize, nei: &[Vec<usize>], a: &mut Vec<usize>, b: &mut Vec<usize>) {
    a.push(now);
    for &n in nei[now].iter() {
        if n == pre {
            continue;
        }
        dfs(n, now, nei, b, a);
    }
}

fn main() {
    input! {
        n: usize,
        ab: [(usize1, usize1); n - 1],
    };
    let nei = {
        let mut nei = vec![vec![]; n];
        for (a, b) in ab {
            nei[a].push(b);
            nei[b].push(a);
        }
        nei
    };
    let mut a = Vec::new();
    let mut b = Vec::new();
    dfs(0, 0, &nei, &mut a, &mut b);

    let zero_num = n / 3;
    let mut ans = vec![0; n];
    if b.len() < a.len() {
        std::mem::swap(&mut a, &mut b);
    }
    if a.len() <= zero_num {
        let mut used = HashSet::with_capacity(a.len());
        for (i, a) in a.into_iter().enumerate() {
            let j = (i + 1) * 3;
            ans[a] = j;
            used.insert(j);
        }
        for i in 1..n + 1 {
            if used.contains(&i) {
                continue;
            }
            ans[b.pop().unwrap()] = i;
        }
    } else {
        for i in 0..(n + 2) / 3 {
            ans[a.pop().unwrap()] = i * 3 + 1;
        }
        for i in 0..(n + 1) / 3 {
            ans[b.pop().unwrap()] = i * 3 + 2;
        }
        let mut i = 3;
        for a in a {
            ans[a] = i;
            i += 3;
        }
        for b in b {
            ans[b] = i;
            i += 3;
        }
    }
    for a in ans {
        print!("{} ", a);
    }
    println!();
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> bool chmax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main() {
    int n, a;
    multiset<int> ms;
    cin >> n;
    while (n--) {
        cin >> a;
        auto it = ms.lower_bound(a);
        if (it == ms.begin()) {
            ms.insert(a);
        }
        else {
            ms.erase(--it);
            ms.insert(a);
        }
    }
    cout << ms.size() << endl;

    return 0;
}

Measured memory_bytes: 8196
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int max = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] >= max) {
                count++;
                max = h[i];
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22996
#include <iostream>
using namespace std;
#define MAX 200000
int main(void){
    int n,p[MAX];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int min=p[0];
    int match;
    for(int i=0;i<n;i++){
        if(p[i]<=min){
            min=p[i];
            match++;
        }
    }
    cout<<match;
}


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

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

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

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	int n;
	cin >> n;
	ll* a = new ll[n];
	rep(i, n) cin >> a[i];

	ll** dp = new ll*[n/2];
	rrep(i, n / 2 - 1) {
		dp[i] = new ll[2 + (n&1)];

		rep(j, 2 + (n & 1)) {
			if (i == n / 2 - 1) {
				dp[i][j] = a[i * 2 + j];
			}
			else {
				dp[i][j] = dp[i + 1][j] + a[i * 2 + j];
				REP(k, j + 1, 2 + (n & 1)) {
					dp[i][j] = max(dp[i][j], dp[i + 1][k] + a[i * 2 + j]);
				}
			}
		}
	}

	ll ans = max(dp[0][0], dp[0][1]);
	if (n & 1) ans = max(ans, dp[0][2]);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 9084
#include <iostream>
#include <list>

typedef std::list<int> TList;
TList Input()
{
    TList List;
    int Count;
    std::cin >> Count;
    for(int i = 0; i < Count; ++i){
        int t;
        std::cin >> t;
        List.push_back(t);
    }
    return List;
}
void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << " " << *It;
    }
    std::cout << std::endl;
}
void InsertSort(TList& List)
{
    typedef TList::iterator TIt;
    TIt i = List.begin();
    while(i != List.end()){
        TIt l = std::lower_bound(List.begin(), i, *i);
        List.insert(l, *i);
        i = List.erase(i);
        Output(List);
    }
}
int main()
{
    TList List = Input();
    InsertSort(List);
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		int y = Integer.parseInt(s.substring(0, 4));
		int m = Integer.parseInt(s.substring(5, 7));
		int d = Integer.parseInt(s.substring(8, 10));

		if(y < 2019) {
			System.out.println("Heisei");
		}else if(y == 2019 && m < 4) {
			System.out.println("Heisei");
		}else if(y == 2019 && m == 4 && d <= 30) {
			System.out.println("Heisei");
		}else {
			System.out.println("TBD");
		}
	}
}

Measured memory_bytes: 21968
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj
 
typedef long long ll;
 
using namespace std;
 
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(5);
    rep(i, 5){
        cin >> a[i];
    }
    sort(ALL(a));
    print(4 + (ll) ceil((double)n / (double)a[0]));
}

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

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

    int n, k;
    cin >> n >> k;

    int r, s, p;
    cin >> r >> s >> p;
    vector<int> point(128, 0);
    point['r'] = p;
    point['s'] = r;
    point['p'] = s;

    string t;
    cin >> t;

    vector<vector<ll> > dp(t.size() + 1, vector<ll>(3, 0));
    vector<int> v(100001, 0);

    REP(i, n) REP(j, 3) {
        if (i - k >= 0 && v[i - k] && t[i] == t[i - k])
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        else {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + point[t[i]]);
            v[i] = 1;
        }
    }

    ll ans = 0;
    REP(i, 3) ans = max(ans, dp[n][i]);
    cout << ans << '\n';

    // vector<int> v(100001, 0);
    // int ans = 0;
    // REP(i, n) {
    //     if (i - k >= 0  && v[i - k] && t[i] == t[i - k]) continue ;
    //     if (t[i] == 'r') ans += p;
    //     if (t[i] == 's') ans += r;
    //     if (t[i] == 'p') ans += s;
    //     v[i] = 1;
    // }
    // int ans = 0;
    // cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,a,b;cin>>n>>a>>b;
    ll x = n/(a+b), y = n%(a+b);
    cout<<x*a+min(a,y);
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int D = in.nextInt();
        double[][] arr = new double[N][D];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < D; ++j) {
                arr[i][j] = in.nextDouble();
            }
        }

        int ans = 0;
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < i; ++j) {
                if (integerDistance(arr[i], arr[j])) 
                    ++ans;
            }
        }

        System.out.println(ans);
    }

    private static boolean integerDistance(double[] a, double[] b) {
        // a & b guaranteed to have same length
        double dist = 0;
        for (int i = 0; i < a.length && i < b.length; ++i) {
            dist += sq(a[i] - b[i]);
        }
        return isInteger(dist);
    }

    private static boolean isInteger(double d) {
        double sqrt = Math.floor(Math.sqrt(d));
        return sqrt * sqrt == d;
    }

    private static double sq(double a) {
        return a * a;
    }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int out = -1;
  bool stop = false;
  for (int i = (A*100+7)/8; i < (A+1)/0.08; i++) {
    for (int j = (B*100+9)/10; j < (B+1)/0.1; j++) {
      if (i == j) {
        out = i;
        stop = true;
        break;
      }
    }
    if (stop) break;
  }
  cout << out << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,l,r;
	cin>>a>>l>>r;
	for(int i=l;i<=r;i++)
	{
		if(i%a==0)
		{
			puts("OK");
			return 0;
		}
	}
	puts("NG");
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {




	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力

	int h = sca.nextInt();
	int a = sca.nextInt();

	int ans = 0;
	if(h % a  > 0) {
		System.out.println(h/a + 1);
	}
	else {
		System.out.println(h/a);
	}

	// 後始末
	sca.close();
	}
}

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

using namespace std;

void solve(){
    int k, x;
    cin >> k >> x;
    for (int stone = x-k+1; stone <= x+k-1; stone++){
        cout << stone << ' ';
    }
    cout << '\n';
}

int main(){
    //int t; cin >> t; while(t--)
        solve();
}

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

int main(){
    ll r,D,prev_x;
    cin >> r >> D >> prev_x;
    rep(i,10){
        ll new_x = r * prev_x - D;
        prev_x = new_x;
        cout << new_x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
S0 = list(input())
T = list(input())
m = len(S0)
n = len(T)

def f(s,c):
    for i in range(len(s)):
        if s[i] == '?':
            s[i] = c
    return s

res = ['{']

for i in range(m-n+1):
    tmp = S0[:]
    for j in range(n):
        if tmp[i+j] == '?':
            tmp[i+j] = T[j]
        elif tmp[i+j] != T[j]:
            break
        if j == n-1:
            tmp = f(tmp,'a')
            res = min(res,tmp)

if res == ['{']:
    print('UNRESTORABLE')
else:
    print(''.join(res))

Measured memory_bytes: 3064