akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define INF 100000000

int main() {
    int N, M, R, c[200][200];
    vector<int> r;
    REP(i, 200) fill(c[i], c[i] + 200, INF);
    cin >> N >> M >> R;
    REP(i, R) {
        int tmp;
        cin >> tmp; tmp--;
        r.push_back(tmp);
    }
    sort(ALL(r));
    REP(i, M) {
        int A, B, C;
        cin >> A >> B >> C; A--; B--;
        c[A][B] = c[B][A] = C;
    }
    REP(k, N) REP(i, N) REP(j, N)
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    int ans = INF;
    do {
        int cost = 0;
        REP(i, r.size() - 1) {
            cost += c[r[i]][r[i + 1]];
        }
        ans = min(ans, cost);
    } while (next_permutation(ALL(r)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
A,B,C,D = map(int, input().split())
CC=B//C-(A-1)//C
DD=B//D-(A-1)//D
import fractions
F=(C*D)//fractions.gcd(C,D)
FF=B//F-(A-1)//F
print(B-A+1-CC-DD+FF)


Measured memory_bytes: 5688
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long int a[n];
    long long int r[100001]={0};
    long long int sum=0;
    for(int i=0;i<n;i++)
       {
        cin>>a[i];
        r[a[i]]++;
        sum+=a[i];
       }
    int q;
    cin>>q;
    //sum=accumulate(a,a+n,0);
    for(int i=0;i<q;i++)
    {
            int b,c;
            cin>>b>>c;
            sum-=(long long int)(b*r[b]);
            sum+=(long long int)(r[b]*c);
            r[c]+=r[b];
            r[b]=0;
            cout<<sum<<"\n";
    }
}



Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,l,r) for(int i=l;i<=r;i++)
int main()
{   //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int h[n+1];
    int dp[n+1];
    for(int i=1;i<=n;i++)cin>>h[i];

        h[0]=h[1];
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=n;i++)
    { int mn=INT_MAX;
        for(int j=1;j<=k && j<=i;j++)
        mn=min(dp[i-j]+abs(h[i]-h[i-j]),mn);
        
        dp[i]=mn;
    }
   cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

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

int main() {
	int n;
	cin >> n;
	long double x[10];
	string u[10];
	long double ans = 0.0;
	rep(i, n) {
		cin >> x[i] >> u[i];
		if (u[i] == "JPY")ans += x[i];
		else ans += x[i] * 380000.0;
	}
	cout << ans << endl;
	
	
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int k,n;
    cin >> k >> n;
    int dis[n];
    for(int i=0;i<n;i++) cin >> dis[i];
    int ans = dis[n-1]-dis[0];
    for(int i=1;i<n-1;i++){
    	ans = min(ans,k-dis[i+1]+dis[i]);
	}
    cout << ans << "\n";
    
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a + b >= c - 1) {
      System.out.println(b + c);
    } else {
      System.out.println(a + 2 * b + 1);
    }
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

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

    int SZ = 1200;
    vector<bool> isPrime(SZ, true);
    vector<int> prime;
    isPrime[0] = isPrime[1] = false;
    REP(i, 2, SZ) {
        if (isPrime[i]) {
            prime.push_back(i);
            for (int j = i * 2; j < SZ; j += i) {
                isPrime[j] = false;
            }
        }
    }

    int P = prime.size();
    int n, k;
    while (cin >> n >> k, n + k) {
        auto dp = make_v(P + 1, n + 1, k + 1, 0LL);
        dp[0][0][0] = 1;
        REP(i, 0, P) {
            REP(j, 0, n + 1) {
                REP(t, 0, k + 1) {
                    if (j + prime[i] <= n && t + 1 <= k) {
                        dp[i + 1][j + prime[i]][t + 1] += dp[i][j][t];
                    }
                    dp[i + 1][j][t] += dp[i][j][t];
                }
            }
        }
        cout << dp[P][n][k] << endl;
    }
    return 0;
}



Measured memory_bytes: 36164
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000007
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
// #define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	pii v[200002];
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int,int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int r = v[i].s;

		auto it = mp.lower_bound(v[i].f);


		if(r==w) {
			while(it!=mp.end() && it->f <= r) {
				auto it1 = it++;
				auto it2 = mini.find(it1->s);
				if(it2->s==1) mini.erase(it2);
				else it2->s --;
				mp.erase(it1);
			}

			if(mini.size()==0) cout<<-1<<endl;
			else cout<<mini.begin()->f+i+1<<endl;
		}
		else {
			int mn = inf;

			while(it!=mp.end() && it->f <= r) {
				mn = min(mn, r+1-(it->f)+(it->s));
				auto it1 = it++;
				auto it2 = mini.find(it1->s);
				if(it2->s==1) mini.erase(it2);
				else it2->s --;
				mp.erase(it1);
			}

			if(mn<inf) {
				if(it!=mp.end() && it->f == r + 1) {
					if(it->s > mn) {
						auto it1 = mini.find(it->s);
						if(it1->s ==1) mini.erase(it1);
						else it1->s --;
						mini[mn]++;
						it->s = mn;
					}
				}
				else {
					mp.emplace_hint(it,r+1,mn);
					mini[mn]++;
				}
				cout<<mini.begin()->f+i+1<<endl;
			}
			else {
				if(mini.size()==0) cout<<-1<<endl;
				else cout<<mini.begin()->f+i+1<<endl;
			}

		}

	}
}

Measured memory_bytes: 14620
S = input()
N = len(S)
ans = [1] * N

for i in range(N):
  if S[i] == "R":
    if S[i+1] == "R":
      ans[i+2] += ans[i]
      ans[i] = 0

for i in range(N-1, -1, -1):
  if S[i] == "L":
    if S[i-1] == "L":
      ans[i-2] += ans[i]
      ans[i] = 0

print(" ".join(map(str, ans)))

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

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

    string arr[3];
    for (int i = 0; i < 3; i++) {
        cin >> arr[i];
    }
    for (int j = 0; j < 3; j++) {
        cout << arr[j].front();
    }
}

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 INF = 1e9;

struct Edge{
    /*辺の情報を入れる構造体で行き先とコストを表している*/
    int to;
    ll cost;
    Edge(int to, ll cost) : to(to), cost(cost) {}
};

vector<Edge> g[100005];
vector<ll> dist(100005);

void dfs(int u, int p){
    for(auto v : g[u]){
        if(v.to == p) continue;
        dist[v.to] = dist[u] + v.cost;
        dfs(v.to, u);
    }
}

int main(void){
    int n;
    cin>>n;
    rep(i, n-1){
        int a, b;
        ll c;
        cin>>a>>b>>c;
        --a;--b;
        g[a].push_back(Edge(b, c));
        g[b].push_back(Edge(a, c));
    }
    int q, k;
    cin>>q>>k;
    --k;
    vector<pair<int, int> > v(q);
    rep(i, q){
        int x, y;
        cin>>x>>y;
        --x;--y;
        v[i] = make_pair(x, y);
    }
    rep(i, n) dist[i] = INF;
    dist[k] = 0;
    dfs(k, -1);
    rep(i, q){
        cout<<dist[v[i].first] + dist[v[i].second]<<endl;
    }
    return 0;
}

Measured memory_bytes: 15104
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int[] ans = new int[250000];
		for (int i=1;i<=500;i++) for (int j=i+1;j<=500;j++) 
			ans[j*(j+1)/2 - i*(i-1)/2]++;
		for (;;) {
			int n = sc.nextInt();
			if ( n == 0) break;
			System.out.println(ans[n]);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 22756
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>void chmin(T &a,T b){a=min(a,b);}
using namespace std;

void solve(){
	string s;
	cin>>s;
	int cs=0,ct=0;
	rep(i,s.size()){
		if(s[i]=='S')++cs;
		else {
			if(cs>ct)++ct;
		}
	}
	cout<<s.size()-2*min(cs,ct)<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 720
#include<iostream>

using namespace std;

int main()
{
  	int a;
  	cin >> a;
  	int k = (a / 1.08);
  	if(int(k * 1.08) == a){
      cout << k << "\n";
    }
  	else if(int((k + 1) * 1.08) == a){
    	cout << k + 1 << "\n";
    }
  	else{
      cout << ":(";
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(a) (a).begin(),(a).end()

const int kN = 1002;
int N, M, NN;
int a[kN];
int m[kN*kN];

int solve() {
  sort(a, a + N);
  sort(m, m + NN);  
  if (binary_search(a ,a + N, M)
      || binary_search(m, m + NN, M)) {
    return M;
  }

  rep(i,NN) {
    int val = m[i];
    if (val > M) continue;
    if (binary_search(a, a + N, M - val)
        || binary_search(m, m + NN, M - val)) {
      return M;
    }
  }

  int ans = -1;
  rep(i,NN) {
    int val = m[i];
    if (val > M) continue;
    int *p = lower_bound(a, a + N, M - val);
    --p;
    // printf("val=%d, *p=%d\n", val, *p);
    ans = max(ans, val + *p);
    p = lower_bound(m, m + NN, M - val);
    --p;
    ans = max(ans, val + *p);
    // printf("-val=%d, *p=%d\n", val, *p);
  }
  return ans;
}

int main() {
  while (cin >> N >> M, N | M) {
    rep(i,N) cin >> a[i];
    rep(i,N) rep(j,N) {
      m[i * N + j] = a[i] + a[j];
    }
    NN = N * N;
    printf("%d\n", solve());
  }
  
  return 0;
}

Measured memory_bytes: 5076
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

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




void solve(){
	int n; cin>>n;
	int ans=0;
	int val=1;
	f(i,0,n) {
		val*=10;
		val%=mod;
	}
	ans+=val;
	ans%=mod;
	val=1;
	f(i,0,n) {
		val*=9;
		val%=mod;
	}
	ans-=2*val;
	ans%=mod;
	val=1;
	f(i,0,n) {
		val*=8;
		val%=mod;
	}
	ans+=val;
	ans%=mod;
	if(ans<0) ans+=mod;
	cout<<ans<<"\n";
}


int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
  	int t=1;// cin>>t;
  	while(t--) solve();
 	return 0;
}

Measured memory_bytes: 3588
def sieve(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False

    p = 0
    for i in range(2,n+1):
        if is_prime[i]:
            p = i
            for j in range(p+p, n+1, p):
                is_prime[j] = False
        
        if p * p > n:
            break
    
    primes = []
    for i in range(2,n+1):
        if is_prime[i]:
            primes.append(i)

    return primes

def solve():
    N = int(input())
    primes = sieve(55555)
    ans = []
    for prime in primes:
        if prime % 5 == 1:
            ans.append(str(prime))

        if len(ans) == N:
            break
    
    print(" ".join(ans))

if __name__ == '__main__':
    solve()

Measured memory_bytes: 39152
//It is made by M_sea
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=1000000+10;
const int mod=1e9+7;

int f[N];

int main() {
    int n=read();
    f[n]=n,f[n-1]=1ll*n*n%mod;
    for (re int i=n-2,s=0;i>=1;--i) {
        s=(s+f[i+3])%mod;
        f[i]=(s+i+1+1ll*(n-1)*(n-1)%mod+f[i+1])%mod;
    }
    printf("%d\n",f[1]);
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#pragma GCC target("popcnt")

#define ul unsigned long long
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define dnew cerr<<endl;
#define endl '\n'

using namespace std;

vector<int>vec, dp;
int main(){
      ios::sync_with_stdio(false); cin.tie(nullptr);
      int n; cin>>n;
      vec.resize(n);
      dp.resize(n,INT_MAX);
      for (int i=0; i<n; i++) 
            cin>>vec[i];

      dp[0]=0;
      dp[1]=abs(vec[0]-vec[1]);
      for (int i=2; i<n; i++) 
            dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i]-vec[i-2]));

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

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//forとか代入しない場合は++iでもi++でも同じ


int main() {
    int N, M; cin >> N >> M;
    vector<vector<int> > s(M);
    for (int i = 0; i < M; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int a; cin >> a; --a;
            s[i].push_back(a);
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; ++i) cin >> p[i];
    
    long long res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int con = 0;
            for (auto v : s[i]) {
                //onを希望するvが実際についているかをbitで確かめる
              //今回のポイントはbit&をするのをSからとること
                if (bit & (1<<v)) ++con;
            }
            if (con % 2 != p[i]) ok = false;
        }
        if (ok) ++res;
    }
    cout << res << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		// 入力
		int Ayard = Integer.max(0, sc.nextInt()-1);
		int Byard = Integer.max(0, sc.nextInt()-1);

		// 面積の出力
		System.out.println(Ayard * Byard);
		sc.close();
	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
const int maxn=200005;
const int inf=0x3f3f3f3f;
int n,m,l,r;
vector<int> v[maxn];
struct node {
    int l,r,lz,mmax;
    inline void update(int v) {
        lz+=v;
        mmax+=v;
    }
} seg[maxn<<2];
inline void pushup(int x) {
    seg[x].mmax=max(seg[x<<1].mmax,seg[x<<1|1].mmax);
}
inline void pushdown(int x) {
    int lz=seg[x].lz;
    if (lz) {
        seg[x<<1].update(lz);
        seg[x<<1|1].update(lz);
        seg[x].lz=0;
    }
}
void build(int x,int l,int r) {
    seg[x].l=l,seg[x].r=r;
    if (l==r) {
        seg[x].mmax=l;
        return;
    }
    int m=(l+r)>>1;
    build(x<<1,l,m);
    build(x<<1|1,m+1,r);
    pushup(x);
}
void update(int x,int l,int r,int v) {
    int L=seg[x].l,R=seg[x].r;
    if (l<=L&&r>=R) {
        seg[x].update(v);
        return;
    }
    pushdown(x);
    int m=(L+R)>>1;
    if (m>=l)
        update(x<<1,l,r,v);
    if (m<r)
        update(x<<1|1,l,r,v);
    pushup(x);
}
int query(int x,int l,int r) {
    int L=seg[x].l,R=seg[x].r;
    if (l<=L&&r>=R)
        return seg[x].mmax;
    pushdown(x);
    int ret=-inf,m=(L+R)>>1;
    if (m>=l)
        ret=max(ret,query(x<<1,l,r));
    if (m<r)
        ret=max(ret,query(x<<1|1,l,r));
    pushup(x);
    return ret;
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;++i) {
        scanf("%d%d",&l,&r);
        v[l].push_back(r);
    }
    build(1,0,m+1);
    int res=max(0,n-m);
    for (int i=0;i<=m;++i) {
        for (auto x:v[i])
            update(1,0,x,1);
        res=max(res,query(1,i+1,m+1)-m-i-1);
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int a, b, c;

int main()
{
    cin >> a >> b >> c;
    cout << a + b + c - max({a, b, c}) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    string S;
    cin >> S;
    string T;
    cin >> T;
    ll N=S.size();
    ll M=T.size();
    if(N<M){
        print("UNRESTORABLE")
        return 0;
    }
    //iからi+M-1までみる
    for(ll i=N-M;i>=0;i--){
        bool ok=1;
        for(ll j=i;j<i+M;j++){
            if(S[j]=='?'||S[j]==T[j-i])continue;
            else {ok=0;break;}
        }
        if(ok){
            for(ll j=i;j<i+M;j++){
                S[j]=T[j-i];
            }break;
        }
        if(!ok&&i==0){
            print("UNRESTORABLE")
            return 0;
        }
    }
    for(ll i=0;i<N;i++){
        if(S[i]=='?')cout<<'a';
        else cout<<S[i];
    }cout<<endl;

    return 0;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000;
constexpr auto MOD = 1000000007;

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

	if (n % 2) {
		cout << "0" << endl;
		return 0;
	}

	n /= 2;

	ll ans = 0;
	while (n) {
		n /= 5;
		ans +=n;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100
int main(void) {
  int n, a[MAX];
  int i, j, tmp;
  int cnt = 0;

  scanf("%d", &n);

  if(!(1 <= n && n <= MAX))
    return 0;

  for (i = 0; i < n; i++){
    scanf("%d", &a[i]);
    if(!(0 <= a[i] && a[i] <= MAX))
      return 0;
  }

  for (i = 0; i < n; i++) {
    for (j = 1; j < n - i; j++) {
      if (a[j - 1] > a[j]) {
        tmp = a[j - 1];
        a[j - 1] = a[j];
        a[j] = tmp;
        cnt++;
      }
    }
  }

  printf("%d", a[0]);
  for (i = 1; i < n; i++)
    printf(" %d", a[i]);
  printf("\n%d\n", cnt);

  return 0;
}

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

int main()
{	
	int r,c;
	int i, j;
	cin >> r >> c;
	int A[101][101] = { {} };
	for (i = 0;i < r;i++) {
		for (j = 0;j < c;j++) {
			cin >> A[i][j];
			A[r][c] += A[i][j];
			A[r][j] += A[i][j];
			A[i][c] += A[i][j];
		}
	}
	
	for (i = 0;i <= r;i++) {
		for (j = 0;j <= c;j++) {
			cout << A[i][j];
			if (j != c)cout << ' ';
		}
		cout << endl;
	}

	return 0;
}


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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if ((i % 2 == 1 && s[i] == 'R') || (i % 2 == 0 && s[i] == 'L')) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
N = gets.to_i
A,B,C,D,E = 5.times.map { gets.to_i }

# 最小の旅客人数(ボトルネック)を見つける
min_p = [A,B,C,D,E].min

# 人数をボトルネックとなる都市の旅客人数で割る
# ボトルネック都市以外は1分で着くので * 4を足す
# 割り切れない場合を考慮して切り上げロジックを入れる
puts (N+min_p-1)/min_p + 4

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=105;
const int MAXM=1005;
const int INF=0x3f3f3f3f;
int a[MAXM],b[MAXM],c[MAXM];
int dp[MAXN][MAXN];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    memset(dp,INF,sizeof(dp));
    for(int i=1;i<=n;i++)
        dp[i][i]=0;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        dp[a[i]][b[i]]=min(dp[a[i]][b[i]],c[i]);
        dp[b[i]][a[i]]=min(dp[b[i]][a[i]],c[i]);
    }
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    int res=0;
    for(int k=1;k<=m;k++)
    {
        int isok=1;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                isok&=(dp[i][a[k]]+dp[b[k]][j]+c[k]!=dp[i][j]);
        res+=isok;
    }
    return 0*printf("%d\n",res);
}

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

long long n,l[300005],d[300005],r=0;;
string s;

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

    cin>>n;
    cin>>s;

    l[0]=(s[0]=='W');
    for(int i=1;i<n;i++)
        l[i]=l[i-1]+(s[i]=='W');
    d[n-1]=(s[n-1]=='E');
    for(int i=n-2;i>=0;i--)
        d[i]=d[i+1]+(s[i]=='E');

    r=min(d[0],l[n-1]);
    for(int i=1;i<n-1;i++)
        r=min(r,l[i-1]+d[i+1]);

    cout<<r<<endl;

    return 0;
}


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

int judge(string s, int x)
{
    bool cnt = true, lisb = false, risb = false;
    int resl = 0, resr = 0;
    for (int i = x - 1; - 1 < i; i--)
    {
        if (s[i] == 'W')
        {
            //if(cnt)lisb = false;
            cnt = false;
        }
        else if (s[i] == 'B')
        {
            if (cnt)
                resl++;
            lisb = true;
        }
        else
        {
            if (cnt)
            {
                resl = 0;
            }
            break;
        }
    }

    cnt = true;
    for (int i = x + 1; i < (int)s.size(); i++)
    {
        if (s[i] == 'W')
        {
            //if(cnt)risb = false;
            cnt = false;
        }
        else if (s[i] == 'B')
        {
            if (cnt)
                resr++;
            risb = true;
        }
        else
        {
            if (cnt)
            {
                resr = 0;
            }
            break;
        }
    }

    if(lisb && risb){
        return 0;
    }
    //cout<<resl<<" "<<resr<<endl;
    return resl + resr;
}
signed main()
{
    int l, ans = 0;
    cin >> l;
    string s;
    cin >> s;
    s="."+s+".";

    for (int i = 1; i < (int)s.size()-1; i++)
    {
        if (s[i] == '.')
        {
            ans = max(ans, judge(s, i));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;ll int amt,w;ll int ans;
void stockBuySell(ll int price[],ll int n) 
{ 
    // Prices must be given for at least two days 
    if (n == 1) 
        return; 
  
    // Traverse through given price array 
    ll int i = 0; 
    while (i < n - 1) { 
  		ll int buy=INT_MIN,sell=INT_MIN;
        // Find Local Minima 
        // Note that the limit is (n-2) as we are 
        // comparing present element to the next element 
        while ((i < n - 1) && (price[i + 1] <= price[i])) 
            i++; 
  
        // If we reached the end, break 
        // as no further solution possible 
        if (i == n - 1) 
            break; 
  
        // Store the index of minima 
        buy = i++; 
  
        // Find Local Maxima 
        // Note that the limit is (n-1) as we are 
        // comparing to previous element 
        while ((i < n) && (price[i] >= price[i - 1])) 
            i++; 
  
        // Store the index of maxima 
        sell = i - 1; 

        if(buy<sell)
        {
        	w=amt/price[buy];
        	amt-=price[buy]*w;
        	amt+=w*price[sell];
        	ans=amt;

        }
        else if(buy==INT_MIN || sell==INT_MIN)
        {
        	return;
        }
  
        
    } 
} 


int main()
{
    fast;
    ll int n;
    cin>>n;
    ll int a[n];
    amt=1000,ans=1000;
    for(ll int i=0;i<n;i++)
    	cin>>a[i];
    stockBuySell(a,n);
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
nm=input().split()
n=int(nm[0])
m=int(nm[1])
rg=[]
t=0
for i in range(m):
    a=input().split()
    rg.append((int(a[0]),int(a[1])))
for j in rg:
    for l in rg:
        if j[0]==l[0] and j[1]!=l[1]:
            t=1
            break
    if t==1:
        break
rgg=list(set(rg))
if t==1:
    print(-1)

else:
    for p in rgg:
        if n!=1 and p[0]==1 and p[1]==0:
            t+=1
            print(-1)
            break
    if t!=1:
        
        for q in rgg:
            t+=(10**(n-q[0]))*q[1]
        if n==1 and t==0:
            pass
        elif t<10**(n-1) :
            t+=10**(n-1)
        print(t)


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H + 1, vector<char>(W + 1));
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j)
      cin >> a[i][j];

  vector<vector<int>> dp(H + 1, vector<int>(W + 1, 0));
  dp[1][1] = 1;
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j)
      if (a[i][j] != '#')
        dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % 1000000007;

  cout << dp[H][W] << endl;
}

Measured memory_bytes: 5248
//kalyanchirla
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
#define int long long
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define csl ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007

int32_t main()
{ 
    csl;

    int n;
    cin >> n;

    int arr[n]; 

    for(int i=0;i<n;i++) cin >> arr[i];

    vi suff(n+1,0);

    for(int i=n-1;i>=0;i--)
    {
        suff[i] =  (suff[i+1]%mod + arr[i]%mod)%mod;
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        sum+=(((arr[i]%mod)*suff[i+1]%mod)%mod);
    }
    cout << sum%mod << "\n";
}

Measured memory_bytes: 6368
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

typedef long long ll;

int N;
ll l[100 + 10];

int main() {
	//No sub撤退しないぞ
	cin >> N;
	for (int i = 0; i < N; i++)cin >> l[i];

	if (N <= 2) {
		cout << 0 << endl;
		return 0;
	}

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i])continue;
				vector<ll> tmp;
				tmp.push_back(l[i]);
				tmp.push_back(l[j]);
				tmp.push_back(l[k]);
				sort(tmp.begin(), tmp.end());
				if (tmp[0] + tmp[1] > tmp[2] && tmp[2] - tmp[0] < tmp[1] && tmp[2] - tmp[1] < tmp[0]) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main() {
	int ch;
	stack<int> S1;
	stack<pair<int,int> > S2;
	int sum = 0;
	int i = 0;
	while ((ch = getchar()) != '\n') {
		switch (ch) {
			case '\\':
				S1.push(i);
				break;
			case '/':
				if (S1.size() > 0) {
			    	int j = S1.top();
				    S1.pop();
				    int a = i - j;
				    sum += a;
				    while (S2.size() >0 && S2.top().first > j) {
					   a += S2.top().second;
					   S2.pop();
			      	}
				    S2.push(make_pair(j,a));
			    }
				break;
		}
		i++;
	}
	cout << sum << endl;
	cout << S2.size();
	vector<int> v;
	while (S2.size() > 0) {
		v.push_back(S2.top().second);
		S2.pop();
	}
	for (int i=v.size() - 1;i>=0;i--) {
		cout << " " << v[i];
	}
	cout << endl;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a[3];
  rep(i, 3) cin >> a[i];
  int f1 = 2, f2 = 1;
  rep(i, 3){
    if(a[i] == 5) f1 -= 1;
    else if(a[i] == 7)f2 -= 1;
  }
  if(f1 == 0 && f2 == 0)cout << "YES" << endl;
  else cout << "NO" << endl;
  system("pause");
}


Measured memory_bytes: 504
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 100005;

int n,m,ans;
int l1[MAXN];
int l2[MAXN];
int r1[MAXN];
int r2[MAXN];

pair<int,int> a[MAXN];
pair<int,int> b[MAXN];

int main()
{
	srand(time(0));
	scanf("%d",&n);
	for (int i = 1;i <= n;i++)
		scanf("%d%d",&a[i].first,&a[i].second);
	sort(a + 1,a + n + 1);
	int MN = 1e9 + 1,flag = 0;
	for (int i = n;i >= 1;i--)
		if (a[i].second < MN)
		{
			b[++m] = a[i];
			flag = i;
			MN = a[i].second;
		}
	l1[0] = 0;
	r1[0] = 1e9;
	for (int i = 1;i <= n;i++)
	{
		l1[i] = max(l1[i - 1],a[i].first);
		r1[i] = min(r1[i - 1],a[i].second);
	}
	l2[n + 1] = 0;
	r2[n + 1] = 1e9;
	for (int i = n;i >= 1;i--)
	{
		l2[i] = max(l2[i + 1],a[i].first);
		r2[i] = min(r2[i + 1],a[i].second);
	}
	for (int i = 1;i <= n;i++)
		ans = max(ans,a[i].second - a[i].first + 1 + max(min(r1[i - 1],r2[i + 1]) - max(l1[i - 1],l2[i + 1]) + 1,0));
	reverse(b + 1,b + m + 1);
	for (int i = 1;i < m;i++)
		ans = max(ans,max(0,b[1].second - b[i].first + 1) + max(0,b[i + 1].second - b[m].first + 1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const ll mod = 1e9 + 7;
int main()
{
	SPEED
	int h, n, a, b;
	cin >> h >> n;

	int arr[n+1][2];

    for(int i=1;i<=n;i++)
    {
    	cin >> a >> b;
       	arr[i][0] = a;
       	arr[i][1] = b;
    }
       
    int dp[h+1][n+1];
    for(int i=1;i<=h;i++)
    {
    	dp[i][0] = INT_MAX;
    }
       
    for(int i=1;i<=h;i++)
    {
       	for(int j=1;j<=n;j++)
       	{
       		if(i<arr[j][0])
       		{
       			dp[i][j] = min(arr[j][1], dp[i][j-1]);
       		}
       		else
       		{
       			dp[i][j] = min(dp[i][j-1], dp[i-arr[j][0]][j]+arr[j][1]);
       		}
       	}
    }

    cout << dp[h][n];
	return 0;
}

Measured memory_bytes: 39424
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(double i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int const INF = 1000000;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    int flag[3]={0,0,0};
    rep(i,n){
        cin>>v[i];
        if(v[i]%4==0){
            flag[0]++;
        }else if(v[i]%2==0){
            flag[1]++;
        }else{
            flag[2]++;
        }
    }
    
    if(flag[1]==0&&flag[0]+1<flag[2]){
        cout<<"No"<<endl;
    }else if(flag[1]!=0&&flag[0]<flag[2]){
        cout<<"No"<<endl;
}else {
        cout<<"Yes"<<endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>

int main() {
  long long N, M;
  std::cin >> N >> M;

  std::vector<long long> A_array(M);
  for (unsigned int i = 0; i < M; ++i) {
    std::cin >> A_array.at(i);
  }

  std::cout << std::max(N - std::accumulate(A_array.begin(), A_array.end(), 0), -1LL) << std::endl;
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
long x;

int main() {
  cin >> x;
  long hoge = x/11;
  long remainder = x%11;
  long additional = 0;
  if (1 <= remainder && remainder <= 6) {
    additional = 1;
  }
  if (7 <= remainder) {
    additional = 2;
  }
  long ans = hoge*2 + additional;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, M;
  cin >> N >> M;
  if (N == -1) {
    int m = 0;
    repp(i, 1, N / 2) {
      cout << i << ' ' << (N + 1 - i) << endl;
      m++;
      if (m == M)
        break;
    }
  } else {
    int m = 0;
    int mx = (N - 1) / 2;
    int l = 1, r = l + mx + 1;
    repr(d, (N - 1) / 2, 1) {
      if (m % 2 == 0) {
        cout << l << ' ' << (l + d) << endl;
        l++;
      } else {
        cout << r << ' ' << (r + d) << endl;
        r++;
      }
      m++;
      if (m == M)
        break;
    }
  }
}

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

typedef long long int LLI;
const LLI MOD = 1e9 + 7;

int N;
int A;
int B;
int C;
int D;
LLI fact[1145];
LLI invfact[1145];
LLI dp[1145][1145];
LLI memo[1145][1145];

LLI inv(LLI n) {
  return n == 1 ? n : inv(MOD % n) * (MOD - MOD / n) % MOD;
}

LLI mypow(LLI base, LLI exp) {
  if (exp == 0) return 1;
  LLI res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base % MOD;
  return res;
}

LLI f(int i, int j) {
  if (j < 0) return 0;
  return dp[i][j];
}

LLI comb(int n, int k) {
  if (n < 0) return 0;
  if (n < k) return 0;
  if (memo[n][k]) return memo[n][k];
  if (k == 0 || k == n) return 1;
  return memo[n][k] = (comb(n-1, k-1) + comb(n-1, k)) % MOD;
}

int main() {
  scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);

  fact[0] = 1;
  invfact[0] = 1;
  for (int i=1; i<=N; i++) {
    fact[i] = fact[i-1] * i % MOD;
    invfact[i] = inv(fact[i]);
  }

  dp[A-1][0] = 1;
  for (int i=A; i<=B; i++) {
    for (int j=0; j<=N; j++) dp[i][j] = dp[i-1][j];
    for (int j=i; j<=N; j++) {
      for (int k=C; k*i<=j && k <= D; k++) {
        LLI t = dp[i-1][j-i*k] * fact[i*k] % MOD;
        t = t * (comb(N + i*k - j, i*k) * invfact[k] % MOD) % MOD;
        t = t * mypow(invfact[i], k) % MOD;
        dp[i][j] = (dp[i][j] + t) % MOD;
      }
    }
  }

  /*for (int i=A; i<=B; i++) {
    for (int j=0; j<=N; j++) {
      printf("%lld ", dp[i][j]);
    }
    puts("");
  }*/

  printf("%lld\n", dp[B][N]);
}


Measured memory_bytes: 19840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();
		int ans;
		if (b%a==0){
			ans = a+b;
		}
		else{
			ans = b-a;
		}
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	// ll t;   cin>>t;
	// for(ll tt = 1; tt <= t; tt++)
	// {
	//     //Code
	    
	// }
	ll n;	cin>>n;
	if(n >= 30)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <utility>
#include <set>
#include <bitset>
#define ls x<<1
#define rs x<<1|1
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(x) scanf("%d", &x)
#define scdd(x,y) scanf("%d%d", &x, &y)
#define scddd(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define eb emplace_back
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define IOS std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppp;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 2*acos(0.0);
const double eps = 1e-13;
const ll mod = 1e9+7;
const int maxn = 200 + 10;
const int maxm = 50000 + 10;

int G[maxn][maxn], col[maxn], dis[maxn][maxn], n;
bool flag=1;

void dfs(int u){
    for(int i=1; i<=n&&flag; i++){
        if(u==i || G[u][i]==inf) continue;
        if(col[u]==col[i]){
            flag=0;
            return;
        }
        if(!col[i]){
            col[i] = -col[u];
            dfs(i);
        }
    }
}

void solve() {
    scd(n);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            scanf("%1d", &G[i][j]);
            if(G[i][j]==0 && i!=j) G[i][j]=inf;
        }
    }
    col[1] = 1;
    dfs(1);
    if(!flag) puts("-1");
    else{
        for(int k=1; k<=n; k++){
            for(int i=1; i<=n; i++){
                for(int j=1; j<=n; j++){
                    if(G[i][k]<inf&&G[k][j]<inf){
                        G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
                    }
                }
            }
        }
        int len=0;
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                if(G[i][j]<inf)
                    len = max(len, G[i][j]);
            }
        }
        printf("%d\n", len+1);
    }
}

int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("ans.txt","w",stdout);
#endif
    //IOS;
    solve();

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define maxn 100010
using namespace std;
typedef long long ll;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
ll n,x,y,z,sum,ans;
ll v1[maxn],v2[maxn];
struct node
{
	ll a,b,c;
}p[maxn];
bool cmp(const node &x,const node &y)
{
	if(x.a-x.b!=y.a-y.b) return x.a-x.b>y.a-y.b;
	if(x.a!=y.a) return x.a>y.a;
	return x.b>y.b;
}
priority_queue<ll,vector<ll>,greater<ll> > q;
int main()
{
	read(x),read(y),read(z),n=x+y+z;
	for(int i=1;i<=n;++i)
	{
		read(p[i].a),read(p[i].b),read(p[i].c);
		sum+=p[i].c,p[i].a-=p[i].c,p[i].b-=p[i].c;
	}
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=x;++i) v1[x]+=p[i].a,q.push(p[i].a);
	for(int i=x+1;i<=n;++i)
	{
		v1[i]=v1[i-1];
		if(p[i].a>q.top()) v1[i]+=p[i].a-q.top(),q.push(p[i].a),q.pop();
	}
	while(!q.empty()) q.pop();
	for(int i=n;i>=n-y+1;--i) v2[n-y+1]+=p[i].b,q.push(p[i].b);
	for(int i=n-y;i;--i)
	{
		v2[i]=v2[i+1];
		if(p[i].b>q.top()) v2[i]+=p[i].b-q.top(),q.push(p[i].b),q.pop();
	}
	for(int i=x;i<=n-y;++i) ans=max(ans,sum+v1[i]+v2[i+1]);
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 7408
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	int a,ans=0,tmp=10;
	bool b=true;
	rep(i,5){
		cin >> a;
		if(a%10!=0){
			tmp=min(tmp,a%10);
			a+=(10-a%10);
			b=false;
		}
		ans+=a;
	}
	if(b) tmp=10;
	cout << ans-(10-tmp) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[1000];
  while(cin>>n,n){
    int mn=1e9;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  for(int i=1;i<n;i++)mn=min(mn,a[i]-a[i-1]);
  cout<<mn<<endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  string C;
  
  for (int i= 0; i < N; i++){
    cin >> C;
    
    if (C == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (i < (N - 1) ) continue;
    
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    N = Number(input[0])
    tmpi = input[1].split(" ");
    tmpj = input[2].split(" ");
    an = 0;
    for(i = 0; i < N; i++){
        yusha = Number(tmpj[i]);
        mons = Number(tmpi[i]);
        c = yusha - mons;
        if(c >= 0) an += mons;
        else an += yusha; 
        if(c <= 0) continue;
        d = Number(tmpi[i+1]) - c;
        if(d >= 0){an += c;tmpi[i+1] =d}
        else{an+=Number(tmpi[i+1]);tmpi[i+1] =0}
    }
    console.log(an);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main(int argc, char *argv[]) {
	int N, X;
	cin >> N >> X;
	vector<int> m(N);

	for (int i = 0; i < N; i++) cin >> m[i];

	sort(begin(m), end(m));

	int ans = N;
	for (int i = 0; i < N; i++) X -= m[i];

	ans += X / m[0];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#define f first
#define s second
#define fore(i,a,b) for(lli i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
    char a;
    lli sum=0;
    while(cin >> a)
    {
      sum+=a-'0';
    }
    if(sum%9==0)
    {
      cout << "Yes" <<ENDL;
    }
    else
    {
      cout << "No" <<ENDL;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll N;
	cin>>N;
	vector<vector<ll>> x(N,vector<ll>(N,-1));
	REP(i,N){
		ll tmp;
		cin>>tmp;
		REP(j,tmp){
			ll a,b;
			cin>>a>>b;
			x[i][a-1]=b;
		}
	}
	ll end=pow(2,N);
	ll ans=0;
	ll tmp=0;
	REP(think,end){
		REP(i,N){
			if(((think>>i)&1)==1){
				REP(j,N){
					if(x[i][j]!=-1 && x[i][j]!=((think>>j)&1)){
						goto Next;
					}
				}
			}
		}
		tmp=0;
		REP(i,N){
			//cout<<((think>>i)&1)<<" ";//
			if(((think>>i)&1)==1)tmp++;
		}
		//cout<<tmp<<endl;
		if(ans<tmp){
			ans=tmp;
		}
		Next:;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (x, y): (i64, i64) = parse_line().unwrap();
    let (a_2, b_2) = (4 * x - y, y - 2 * x);

    if (a_2 % 2 != 0) || (a_2 < 0) {
        println!("No");
        return;
    }
    if (b_2 % 2 != 0) || (b_2 < 0) {
        println!("No");
        return;
    }
    println!("Yes");
}


Measured memory_bytes: 2152