akhauriyash/Code-Regression huggingface dataset:
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n; cin >> n;
  string s; cin >> s;

  map<char, char> mp;
  for(char c = 'A'; c <= 'M'; c++) mp[c] = 'U';
  for(char c = 'N'; c <= 'Z'; c++) mp[c] = 'D';
  for(char c = 'a'; c <= 'm'; c++) mp[c] = 'R';
  for(char c = 'n'; c <= 'z'; c++) mp[c] = 'L';

  int cnt_ud = 0;
  int cnt_rl = 0;

  for(int i = 0; i < (int)s.size(); i++) {
    if(mp[s[i]] == 'U') cnt_ud++;
    if(mp[s[i]] == 'D') cnt_ud--;
    if(mp[s[i]] == 'R') cnt_rl++;
    if(mp[s[i]] == 'L') cnt_rl--;
  }
  
  int num = (int)abs(cnt_ud) + (int)abs(cnt_rl);
  cout << num << endl;

  for(int i = 0; i < n; i++) {
    if(mp[s[i]] == 'U' and cnt_ud > 0){ cout << s[i]; cnt_ud--; }
    if(mp[s[i]] == 'D' and cnt_ud < 0){ cout << s[i]; cnt_ud++; }
    if(mp[s[i]] == 'R' and cnt_rl > 0){ cout << s[i]; cnt_rl--; } 
    if(mp[s[i]] == 'L' and cnt_rl < 0){ cout << s[i]; cnt_rl++; }
  }

  cout << endl;
  return 0;
}



Measured memory_bytes: 3304
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, a[100000], b[100000]; long long sum, ret, dp[100001], rmq[262144];
void update(int i, long long x) { i += 131072; rmq[i] = x; while (i > 1) i /= 2, rmq[i] = max(rmq[i * 2], rmq[i * 2 + 1]); }
long long query(int p, int q, int k, int l, int r) {
	if (r <= p || q <= l) return 0;
	if (p <= l && r <= q) return rmq[k];
	long long vl = query(p, q, 2 * k, l, (l + r) / 2);
	long long vr = query(p, q, 2 * k + 1, (l + r) / 2, r);
	return max(vl, vr);
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]), sum += a[i], b[a[i] - 1] = i;
	for (int i = 1; i <= n; i++) {
		update(a[i - 1] - 1, dp[i] = query(0, a[i - 1], 1, 0, 131072) + a[i - 1]);
		ret = max(ret, dp[i]);
	}
	printf("%lld\n", sum - ret);
	return 0;
}

Measured memory_bytes: 5856
A,B,C,D,E,F = map(int,input().split())
waterset = set()
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        water = (A*i + B *j)*100
        if water < F:
            waterset.add(water)
waterset.remove(0)
sugarset = set()
for i in range(F//C + 1):
    for j in range(F//D + 1):
        sugar = C*i + D*j
        if sugar < F:
            sugarset.add(sugar)
best_conc = -1
best_a = -1
best_b = -1
for a in waterset:
    for b in sugarset:
        if a+b >F:
            continue
        if b > E*a//100:
            continue
        conc = 100*b/(a+b)
        if conc > best_conc:
            best_conc = conc
            best_a = a
            best_b = b
print(best_a+best_b,best_b)

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

using namespace std;

typedef long long llint;
typedef pair <int, int> pi;

const int MAXN = 200005;
const int LOG = 30;

int a = 0, b = 1, nula = 1000, sol = 300, gate = 301;
int pot[LOG];
llint r[MAXN];

void cmp (int i, int j, int k) {
    cout << "< " << i << " " << j << " " << k << endl;
    r[k] = r[i] < r[j];
}

void add (int i, int j, int k) {
    cout << "+ " << i << " " << j << " " << k << endl;
    r[k] = r[i] + r[j];
}

void ispis (int lo, int hi) {
    for (int i = lo; i < hi; i++) cout << r[i] << " "; cout << endl;
}

void gen_pot () {
    add(0, 1, 2);
    add(2, 2, 2);
    cmp(0, 2, 2);
    pot[0] = 2;
    for (int i = 1; i < LOG; i++) {
        pot[i] = i + 2;
        add(pot[i - 1], pot[i - 1], pot[i]);
    }
}

void gen_bin (int pos, int val) {
    int curr = pos + 60, tmp = pos + 61;
    add(val, pot[0], val);

    for (int i = LOG - 1; i >= 0; i--) {
        add(curr, pot[i], tmp);
        cmp(tmp, val, pos + i);
        add(pos + i, nula, pos + i + 30);
        for (int j = 0; j < i; j++) {
            add(pos + i + 30, pos + i + 30, pos + i + 30);
        }
        add(curr, pos + i + 30, curr);
    }
}

void mult_bits (int pos_a, int pos_b, int i, int j) {
    add(pos_a + i, pos_b + j, gate);
    cmp(pot[0], gate, gate);
    for (int k = 0; k < i + j; k++) {
        add(gate, gate, gate);
    }
    add(sol, gate, sol);
}

void solve () {
    for (int i = 0; i < LOG; i++) {
        for (int j = 0; j < LOG; j++) {
            mult_bits(100, 200, i, j);
        }
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //int A, B; cin >> A >> B;
    //r[0] = A; r[1] = B;
    cout << 29945 << endl;
    gen_pot();
    gen_bin(100, a);
    gen_bin(200, b);
    solve();
    add(sol, nula, 2);
    return 0;
}


Measured memory_bytes: 3664
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){

  int n,a,b;
  int x1,x2;

  cin >> n >> a >> b;

  x1 = a*n;
  x2 = b;

  if( x1 < x2){
    cout << x1 << endl;
  }else{
    cout << x2 << endl;
  }


}


Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]
a = 0
for i in range(n - 2 ):
    if (p[i] - p[i+1]) > 0  and p[i+2] - p[i+1] < 0:
        a += 1
    elif (p[i] - p[i+1]) < 0  and p[i+2] - p[i+1] > 0:
        a += 1

print(a)



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

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

  if (N == 1) {
    cout << "Hello World" << endl;
  } else if (N == 2) {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define F first
#define S second
#define INF 1000000000000000000
#define M 1000000007
void YES(bool o){
    if(o)printf("YES\n");
    else printf("NO\n");
}
void Yes(bool o){
    if(o)printf("Yes\n");
    else printf("No\n");
}
ll ans,n,x,p[55],a[55];
void dfs(ll l,ll y){
    if(y==0)return;
    if(a[l]<=y){
        ans+=p[l];
        return;
    }
    if(l==0)return;
    if(a[l-1]+2<=y){
        ans+=p[l-1]+1;
        y-=(a[l-1]+2);
        dfs(l-1,y);
        return;
    }
    dfs(l-1,y-1);
}
int main(void){
    cin>>n>>x;
    p[0]=1,a[0]=1;
    for(int i=1;i<=50;i++)p[i]=p[i-1]*2+1;
    for(int i=1;i<=50;i++)a[i]=a[i-1]*2+3;
    dfs(n,x);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  string S;
  cin >> S;
  vector<int> p;
  vector<int> pp;
  vector<int> ans((int)S.size());
  for(int i=0;i<(int)S.size()-1; i++){
    if((char)S[i] == 'R' && (char)S[i+1]=='L'){
      p.pb(i);
    }
  }
  for(int i=0;i<(int)S.size()-1; i++){
    if((i==0) || ((char)S[i] == 'R' && (char)S[i-1]=='L')){
      pp.pb(i);
    }
  }
  vector<int> cnt;
  int tmp = 1;
  for(int i=0;i<(int)S.size()-1;i++){
    if((char)S[i]=='L' && (char)S[i+1]=='R'){
      cnt.pb(tmp);
      tmp=1;
    }
    else tmp++;
  }
  cnt.pb(tmp);
  //for(auto x:p) cout << x << endl;
  //cout << endl;
  //for(auto x:cnt) cout << x << endl;
  //cout << endl;

  for(int i=0;i<(int)p.size();i++){
    if((p[i] - pp[i])%2==1){
      ans[p[i]] = cnt[i]/2;
      ans[p[i]+1] = (cnt[i]+1)/2;
    }
    else{
      ans[p[i]] = (cnt[i]+1)/2;
      ans[p[i]+1] = cnt[i]/2;
    }
  }

  for(int i=0;i<(int)ans.size();i++){
    if(i==0)cout << ans[i];
    else cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int n,k;
int a[100001];
vector<int> G[100005];
vector<int> rG[100005];
int dist[100005];
 
int main(void){
    scanf("%d%d",&n,&k);
    queue<int> que;
    memset(dist,-1,sizeof(dist));
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>0){
            G[a[i]-1].push_back(i);
            rG[i].push_back(a[i]-1);
        }
    }
    for(int i=0;i<n;i++){
        if(G[i].size()==0){
            que.push(i);
            dist[i]=0;
        }
    }
    while(que.size()){
        int v=que.front();
        que.pop();
        for(int i=0;i<rG[v].size();i++){
            if(dist[rG[v][i]]==-1){
                dist[rG[v][i]]=dist[v]+1;
                que.push(rG[v][i]);
            }
        }
    }
    int res=0;
    for(int i=0;i<n;i++){
        if(dist[i]<k || rG[i].size()==0)res++;
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 15012
package main

import (
	"fmt" //Library for input and output
)

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N+1)
	c := make([]int, N+1)

	for i := 1; i <= N; i++ {
		fmt.Scan(&h[i])
	}

	if N == 1 {
		fmt.Println(0)
		return
	} else if N == 2 {
		fmt.Println(Abs(h[2] - h[1]))
		return
	}

	c[1] = 0
	c[2] = Abs(h[2] - h[1])

	for i := 3; i <= N; i++ {
		c[i] = Min(c[i-1]+Abs(h[i-1]-h[i]), c[i-2]+Abs(h[i-2]-h[i]))
	}

	fmt.Println(c[N])
}

// Abs returns the absolute value of x.
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

// Min returns the min of x and y
func Min(x int, y int) int {
	if x < y {
		return x
	}
	return y
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1000003;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    vector<int> s{1};
    for(int i = 2; s.back() <= 1e6; ++i){
        s.push_back(s.back() + i);
    }
    vector<i64> v{1};
    for(int i = 1; v.back() <= 1e6; ++i)
        v.push_back(v.back() + s[i]);
    s.clear();
    int m = 1e6 + 7;
    vector<int> dist(m, MOD), dist2(m, MOD);
    queue<int> que;
    que.emplace(0);
    dist[0] = 0;
    while(!que.empty()){
        int k = que.front();
        que.pop();
        for(auto x : v)
            if(k + x < m && chmin(dist[k + x], dist[k] + 1))
                que.emplace(k + x);
    }
    que.emplace(0);
    dist2[0] = 0;
    while(!que.empty()){
        int k = que.front();
        que.pop();
        for(auto x : v)
            if(x % 2 == 1 && k + x < m && chmin(dist2[k + x], dist2[k] + 1))
                que.emplace(k + x);
    }
    while(1){
        int k;
        cin >> k;
        if(!k)
            break;
        cout << dist[k] << " " << dist2[k] << endl;
    }
}



Measured memory_bytes: 13976
#include <iostream>

using namespace std;

int uz[100005];

int main()
{
	int n, q, x, y;

	cin >> n >> q;
	uz[1] = 1;
	int poz1 = 1;
	for (int i = 1; i <= q; i++)
	{
		uz[poz1 - 1] = uz[poz1 + 1] = 2;
		cin >> x >> y;
		swap(uz[x], uz[y]);
		if (uz[x] == 1)
			poz1 = x;
		else if (uz[y] == 1)
			poz1 = y;
	}
	uz[poz1 - 1] = uz[poz1 + 1] = 2;
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans += (uz[i] != 0);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long d = sc.nextLong();
		long t = sc.nextLong();
		long s = sc.nextLong();
		if(t*s>=d) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35732
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int cnt;
bool visited[200005];
void dfs(vector<vector<int>>&v,int s)
{
    visited[s]=true;
    cnt++;
    for(int i:v[s])
    {
        if(visited[i]==false)
        {
            dfs(v,i);
        }
    }
}
signed main()
{
	int n,m;
    cin>>n>>m;
    vector<vector<int>>v(n+1);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int res=0;
    for(int i=1;i<=n;i++)
    {
        if(visited[i]==false)
        {
            cnt=0;
            dfs(v,i);
            res=max(res,cnt);
        }
    }
    cout<<res;
}

Measured memory_bytes: 23528
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

class AOddsOfOddness {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n;
		in >> n;

		int odds = 0;
		for(int i = 1; i <= n; i++)
			if (i % 2 == 1)
				odds++;


		out.precision(10);
		out << fixed << (double)odds/(double)n << "\n";

	}
};

int main() {
	AOddsOfOddness solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n;
  double ans = 0;
  double x;
  char u[100] = {};
  int i;

  scanf("%d",&n);

  for (i = 0; i < n; i++) {
    scanf("%lf %s", &x, u);

    if (u[0] == 'J') {
      ans += x;
    } else {
      ans += 380000.0 * x;
    }
  }

  printf("%lf\n", ans);
  
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        int count = 0;
        for(int X = 1; X <= i; X++){
            if(i % X == 0){
                count++;
            }
        }
        if(count == 8){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int s;
		int[] a, b, sum;
		s = 0;
		
		a = new int[200];
		b = new int[200];
		sum = new int[200];
		
		while(scan.hasNext()){
			
			a[s] = scan.nextInt();
			b[s] = scan.nextInt();
			if(a[s] == 0 && b[s] == 0) break;
			
			sum[s] = a[s] + b[s];
			s++;
		}
		
		for(int i = 0; i < s; i++){
			if(sum[i] < 10)System.out.println(1);
			else if(sum[i] < 100)System.out.println(2);
			else if(sum[i] < 1000)System.out.println(3);
			else if(sum[i] < 10000)System.out.println(4);
			else if(sum[i] < 100000)System.out.println(5);
			else if(sum[i] < 1000000)System.out.println(6);
			else System.out.println(7);
		}
	}
}

Measured memory_bytes: 26492
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int A,B,K;
  cin>>A>>B>>K;
  //100までだから全探索
  int counter=0;
  for(int i=100;i>=0;i--){
    if(A%i==0 and B%i==0){
      counter+=1;
    }
    if(counter==K){
      cout<<i<<"\n";
      break;
    }
  }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}
const int D = 60;
int to[D][MX];


signed main(){
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    deque<int> arr;
    FOR(i,1,min(a,b)+1) {
        if(a%i==0&&b%i==0) arr.push_front(i);
    }
    cout << arr[k-1] << endl;
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int N,A,B,C,D;
string s;

int main()
{
    cin >> N >> A >> B >> C >> D >> s;
    A--;B--;C--;D--; 
    bool flag = false;
    if(D < C)
    {
        for(int i = B;i <= D;i++)
        {
            if(s[i] == '.' && s[i+1] == '.' && s[i-1] == '.')
            {
                flag = true;
            }
        }
        if(!flag)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = A; i < C; i++)
    {
        if(s[i] == '#' && s[i+1] == '#')
        {
            cout << "No" << endl;
                return 0;
        }
    }
    for(int i = B; i < D; i++)
    {
        if(s[i] == '#' && s[i+1] == '#')
        {
                cout << "No" << endl;
                return 0;
        }
    }

    cout << "Yes" << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    map<string, int> mp;
    rep(i,n){
        ++mp[s[i]];
    }

    cout << mp.size() << endl;

    return 0;
}

Measured memory_bytes: 25168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
using namespace atcoder;

int main(){
  int N,Q;
  cin>>N>>Q;
  VI T(Q),U(Q),V(Q);
  rep(i,Q) cin>>T[i]>>U[i]>>V[i];
  dsu D(N);
  rep(i,Q){
    if(T[i]){
      if(D.same(U[i],V[i])) cout<<1<<endl;
      else cout<<0<<endl;
    }else D.merge(U[i],V[i]);
  }
}

Measured memory_bytes: 5860
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  REP(i,1,n+1){
    int count=0,sum=0;
    REP(x,1,i){
      REP(y,1,i-x*x-x*y+1){
        REP(z,1,i-x*x-y*y-x*y-x*z+1){
          sum=x*x+y*y+z*z+x*y+y*z+z*x;
          if(sum>i){
            break;
          }
          if(sum==i){
            count++;
          }
        }
      }
    }
    cout<<count<<'\n';
  }
  return(0);
}



Measured memory_bytes: 3648
//1 メモ型

#include <bits/stdc++.h>
using namespace std;
vector<vector<char>>data(1000,vector<char>(1000));//とりあえず、空間は作る。
vector<vector<int>>memo(1000,vector<int>(1000));//その値の格納
vector<vector<int>>done(1000,vector<int>(1000));//その値に訪れたことあるかどうか  
int dp(int p,int q){
  if (done.at(p).at(q)) {
  return memo.at(p).at(q);
  }
  else{
    int res;//端っこはifで処理される
    if (data.at(p).at(q)=='#'){
    res=0;
    memo.at(p).at(q)=res;
    }
      
    else{
    res=(dp(p,q-1)+dp(p-1,q))%1000000007;
    memo.at(p).at(q)=res;
    }
    done.at(p).at(q)=1;
  return res;
  }
}
//この関数dpは2数を引数に持つ。そして このマス目に行くための通りをあたえる
  
  
int main(){
int H,W;
  cin >>H>>W;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
  cin >>data.at(i).at(j);
  }  
  }//入力完了
  memo.at(0).at(0)=1;
  done.at(0).at(0)=1;
  for(int i=1;i<W;i++){
     if (data.at(0).at(i)=='#'){
    memo.at(0).at(i)=0;  //i以下全て0にしたいところ  
    } 
    else{
    memo.at(0).at(i)=memo.at(0).at(i-1);
    }
      done.at(0).at(i)=1;
  }
  
  for(int i=1;i<H;i++){
     if (data.at(i).at(0)=='#'){
    memo.at(i).at(0)=0;  //i以下全て0にしたいところ  
    } 
    else{
    memo.at(i).at(0)=memo.at(i-1).at(0);
    }
      done.at(i).at(0)=1;
  }
cout <<dp(H-1,W-1)<<endl;

}


Measured memory_bytes: 11136
#include <iostream>
using namespace std;
int main(void){
    string a;
    cin>>a;
    if (a[0]==a[1] || a[0]==a[2] || a[1]==a[2] || a[0]==a[1]==a[2]){
        cout<<"No"<<endl;
    }
    else {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI S(1LL << N);
	vector<bool>F(1LL << N, false);
	REP(i, 1LL << N)cin >> S[i];
	rSORT(S);

	PQ Q,tmp;
	Q.push(S[0]);
	F[0] = true;
	
	int cnt = 0;
	while (cnt < N) {
		tmp = Q;
		int i = 0;
		while (!tmp.empty() && i<S.size()) {
			if (tmp.top() > S[i] && !F[i]) {
				Q.push(S[i]);
				F[i] = true;
				tmp.pop();
			}
			i++;
		}
		cnt++;
	}
	REP(i, S.size()) {
		if (!F[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;


	return 0;

}



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


bool check(vector<int> &a, vector<int> &b){
  // 一緒ならtrue
  int n = a.size();
  rep(i, n){
    if (a[i] != b[i]) return false;
  }
  return true;
}

int main() {
  int n; cin >>n;
  vector<int> p(n),q(n);
  rep(i, n) cin >>p[i]; rep(i, n) p[i]--;
  rep(i, n) cin >>q[i]; rep(i, n) q[i]--;
  vector<int> a(n); rep(i, n) a[i] = i;
  int pp = 0, qq = 0;
  ll i = 0;
  do {
    if (check(a, p)) pp = i;
    if (check(a, q)) qq = i;
    i++;
  } while (next_permutation(all(a)));

  ll res = abs(pp - qq);
  cout <<res <<endl; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7)
	{
		cout<<"YES"<<endl;
	}
	else if(a==5&&b==7&&c==5)
	{
		cout<<"YES"<<endl;
	}
	else if(a==7&&b==5&&c==5)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
}

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

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

using namespace std;

int main()
{
  ll K;
  string s;
  cin >> s;
  cin >> K;
  string invalid = "{}";
  vector<string> xs;
  for (auto i = 0; i < K; i++) xs.push_back(invalid);
  make_heap(xs.begin(), xs.end(), greater<string>());
  for (auto i = 0; i < s.size(); i++) {
    ll len = 1;
    for (auto len = 1; len <= 5 && i + len <= s.size(); len++) {
      string t = s.substr(i, len);
//      cout << "i=" << i << " len=" << len << " " << xs.front() << " < " << t << "?=" << (xs.front() < t) << s.size() << endl;
//      cout << xs.front() << " t=" << t << endl;
      if (xs.front() < t) continue;
      bool isin = false;
      for (auto w : xs) if (w == t) isin = true;
      if (isin) continue;
//      cout << "push " << t << endl;
      pop_heap(xs.begin(), xs.end()); xs.pop_back();
      xs.push_back(t); push_heap(xs.begin(), xs.end());
    }
  }
//  return 0;
  while (xs.front() == invalid) {
//    cout << "! pop " << xs.front() << " " << (xs.front()) << " xs.size()=" << xs.size() << endl;
    pop_heap(xs.begin(), xs.end()); xs.pop_back();
  }

  cout << xs.front() << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m,k=map(int,input().split())
friend=[[]for _ in range(n+1)]
block=[[] for _ in range(n+1)]
#union-find
par=[-1]*(n+1)
def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def size(x):
    return -par[find(x)]
def unite(x,y):
    if find(x)==find(y):
        return False
    if size(x)<size(y):
        x,y=y,x
    X=find(x)
    Y=find(y)
    par[X]+=par[Y]
    par[Y]=X
    return True
def is_same(x,y):
    return find(x)==find(y)

for _ in range(m):
    a,b=map(int,input().split())
    friend[a].append(b)
    friend[b].append(a)
    unite(a,b)
for _ in range(k):
    c,d=map(int,input().split())
    if is_same(c,d):
        block[c].append(d)
        block[d].append(c)
ans=[0]*(n+1)

for i in range(1,n+1):
    f=size(i)-1-len(friend[i])
    b=len(block[i])
    ans[i]=f-b
print(*ans[1:], sep=' ')

Measured memory_bytes: 124704
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    vector<int64_t> lefts;
    vector<int64_t> rights;
    int64_t right, left;
    rep(i,m){
        cin >> left >> right;
        if(left == 1){
            lefts.push_back(right);
        }
        if(right == n){
            rights.push_back(left);
        }
    }
    string res = "IMPOSSIBLE";
    sort(lefts.begin(), lefts.end());
    sort(rights.begin(), rights.end());
    int j = 0;
    rep(i, lefts.size()){
        while(rights.size() != j && rights.at(j) <= lefts.at(i)){
            if(lefts.at(i) == rights.at(j)){
                res = "POSSIBLE";
                break;
            }
            j++;
        }
        if(res == "POSSIBLE") break;
    }
    cout << res << endl;
}


Measured memory_bytes: 2004
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N=10005;
int n;
vector<int> vec[N];
int du[N];
int c[N];
bool del[N];
int Ans[N];
int main()
{
	scanf("%d",&n);
	for (int u=1;u<n;u++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);
		vec[y].push_back(x);
		du[x]++;du[y]++;
	}
	for (int u=1;u<=n;u++) scanf("%d",&c[u]);
	sort(c+1,c+1+n);
	int ans=0;
	memset(del,false,sizeof(del));du[0]=1e9;
	for (int u=1;u<=n;u++)
	{
		int mx=0;
		for (int i=1;i<=n;i++) if (!del[i])	mx=du[mx]<du[i]?mx:i;
		ans=ans+du[mx]*c[u];del[mx]=true;Ans[mx]=c[u];
		int siz=vec[mx].size();
		for (int i=0;i<siz;i++) du[vec[mx][i]]--;
	}
	printf("%d\n",ans);
	for (int u=1;u<=n;u++) printf("%d ",Ans[u]);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int A = sc.nextInt();
		double ans = 0;
		
		ans = Math.pow(N, 2) - A;
		
		System.out.println(String.format("%.0f", ans));

		sc.close();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
 	 ll i,n,ans=0;cin>>n;
    string s;
    unordered_map<string,ll> m;
    for(i=0;i<n;i++) 
	{
		
	 cin>>s;
	 sort(s.begin(),s.end());
	 m[s]++;
     }
    for(auto x : m) 
     {
     	ll y=x.second;
     	ans+=(y*(y-1))/2;
	 }
     cout<<ans;
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 10660
#include<iostream>
using namespace std;
string odd = "RUD";
string even = "LUD";
int easy = 1;
int main(){
    string input_string;
    cin >> input_string;
    
    for(int i=0; i< input_string.size(); i++){
        if((i+1)%2){
            if(!(odd.find(input_string[i]) != std::string::npos)){
                easy = 0;
                break;
            }  
        }else{
            if(!(even.find(input_string[i]) != std::string::npos)){
                easy = 0;
                break;
            }  
        }
    }
    if(easy){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//約数列挙
vector<long long> DivAll(long long n) {
	vector<long long> ret;
	long long i = 1;
	for (; i*i < n; i++)
		if (n%i == 0)ret.push_back(i);
	bool flag = i * i == n;
	if (flag)ret.push_back(i);
	for (long long i = (int)ret.size() - 1 - flag; i >= 0; --i)
		ret.push_back(n / ret[i]);
	return ret;
}

VS str = { "perfect number","deficient number","abundant number" };

int main() {
	LL n;
	while (cin >> n && n) {
		VL a = DivAll(n);
		LL sum = accumulate(all(a), 0); sum -= n;
		if (sum == n)cout << str[0] << endl;
		else if (n > sum)cout << str[1] << endl;
		else cout << str[2] << endl;
	}
}


Measured memory_bytes: 3116
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b&&b<c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
return 0;
}

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

bool ok(int n) {
  int v = n % 10;
  while (n > 0) {
    if (n % 10 != v) return false;
    n /= 10;
  }
  return true;
}

int main() {
  int num; cin >> num;
  for (int i = num; ; ++i) {
    if (ok(i)) {
      cout << i << endl;
      return 0;
    }
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

//***********************************
//mintを定義
//***********************************
const int mod = 1000000007;
struct mint {
  int x;
  mint(int x=0):x(x%mod){}   //メンバ変数xをx%modで初期化
  int get() const { return (int)x; }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;           //thisは暗黙的に左辺のポインタ
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
 
  //累乗
  mint mpow(int t) const {
    if (!t) return 1;
    mint a = mpow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  //除算
  mint minv() const {
    return mpow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.minv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
//標準出力
ostream& operator<<(ostream& st, const mint a) 
{ st << a.get(); return st; };
//--------------------------------------------------
 
//***********************************
//場合の数の計算
//***********************************
const int MAX = 200010;
mint fac[MAX], finv[MAX];
 
//前計算
inline void INIT_F(){
    fac[0] = finv[0] = 1;
    for(int i=1; i<MAX-1; i++) {
        fac[i] = (fac[i-1]*mint(i));
        finv[i] = (finv[i-1]/mint(i));
    }
}
 
//nCk
mint mcomb(int n, int k) {
    if(n<k || k<0) return 0;
    else return ((fac[n]*finv[k])*finv[n-k]);
}
 
//nHk
mint mhcomb(int n, int k) {
  return mcomb(n+k-1, k);
}
//--------------------------------------------------

signed main() {
    int N, M;
    cin >> N >> M;
    int S[N], T[M];
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];

    mint dp[N+1][M+1];
    memset(dp, 0, sizeof(dp));
    mint sums[N+1][M+1];
    memset(sums, 0, sizeof(sums));

    rep(i, N) {
        rep(j, M) {
            if(S[i]==T[j]) {
                dp[i+1][j+1] = sums[i][j] + 1;
            } else {
                dp[i+1][j+1] = 0;
            }
            sums[i+1][j+1] = sums[i][j+1] + sums[i+1][j] + dp[i+1][j+1];
            sums[i+1][j+1] -= sums[i][j];
        }
    }

    cout << sums[N][M]+1 << endl;

    return 0;
}

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

using P=pair<int,int>;
const int EPS=1e-7;

int main()
{
   int N; cin>>N;
   vector<P> vp(N);
   for(int i=0;i<N;i++) cin>>vp[i].first>>vp[i].second;

   int Q; cin>>Q;
   while(Q--){
      int l,r; cin>>l>>r;
      auto itr=upper_bound(vp.begin(),vp.end(),P(l,-1));
      double cur=1e9;
      while(itr!=vp.end() and itr->first<r and cur>EPS){
         cur*=(double)(10-itr->second)/10;
         itr++;
      }
      cout<<fixed<<setprecision(10)<<cur<<endl;
   }
   return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
    int to, cost;
};
// other libs
int gcd(int a, int b) {
    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}

class dijkstra {
  private:
    int V;
    int d[100002];
    priority_queue<P, vector<P>, greater<>> que;

  public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

    int find(int e) {
        return d[e];
    }
};
template<typename T>
class Union_Find {
  private:
    vector<T> t, s;

  public:
    Union_Find(T max_length) {
        rep(i, max_length + 1) {
            t.push_back(i);
            s.push_back(1);
        }
    }

    void Union(T x, T y) {
        if (same(x, y))
            return;
        T tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        }
        else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        }
        else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        }
        else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }
    T Find(T n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }

    bool same(T x, T y) {
        return Find(x) == Find(y);
    }

    T get_Size(size_t a) {
        return s[a];
    }
};
bool ifPrime(int n){
    if(n==1)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}
vector<int> primeFactorization(int n) {
    vector<int> re;
    int cnt = 2;
    while (n != 1) {
        if (n % cnt != 0) {
            cnt++;
            continue;
        }
        n /= cnt;
        re.push_back(cnt);
    }
    return re;
}
signed main(signed argc, char* argv[]) {
    int n,m;
    cin>>n>>m;
    priority_queue<int> que;
    rep(i,n){
        int a;
        cin>>a;
        que.push(a);
    }
    rep(i,m){
        int it=que.top();
        que.pop();
        it/=2;
        que.push(it);
    }
    int ans=0;
    while(!que.empty()){
        ans+=que.top();
        que.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
q, h, s, d = map(int, input().split())
n = int(input())

Q = q * 4
H = h * 2
S = s
D = d / 2

if n == 1:
    print(int(min(Q, H, S)))
else:
    if min(Q, H, S) <= D:
        print(int(n * min(Q, H, S)))
    else:
        print((n // 2) * d + (n % 2) * min(Q, H, S))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=998244353;
const double EPS=1e-14;
const bool DEBUG=false;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
void answer(ll N){
    ll sqrt_N = floor(sqrt(N)), answer;
    debug(sqrt_N);
    for(int i=sqrt_N; i>=1; --i){
        if(N % i == 0){
            answer = log10(N/i) + 1;
            debug(i, N/i);
            break;
        }
    }
    cout<<answer<<endl;

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    ll N;
    cin>>N;
    answer(N);

    return 0;
}


Measured memory_bytes: 3896
#include<iostream>
#include<vector>
using namespace std;
#define LL long long
int main () {
  int mod = 1e9 + 7;
  int N, K;
  cin >> N >> K;
  vector<LL>ncr(N + 1, 0);
  vector<LL>ncr_(N + 1, 0);
  vector<LL>Kcr(N + 1, 0);
  vector<LL>Ncr(N + 1, 0);
  ncr[0] = 1;
  for (int i = 1; i <= N; i ++) {
    ncr_[0] = 1;
    ncr_[i] = 1;
    for (int j = 1; j < i; j ++) {
      ncr_[j] = ncr[j - 1] + ncr[j];
      ncr_[j] %= mod;
    }
    if (i == K - 1) {
      for (int j = 0; j <= i; j ++) {
        Kcr[j] = ncr_[j];
      }
    }
    if (i == N - K - 1) {
      for (int j = 0; j <= i; j ++) {
        Ncr[j] = ncr_[j];
      }
    }
    for (int j = 0; j <= i; j ++) {
      ncr[j] = ncr_[j];
    }
  }
  /*for (int i = 0; i <= K; i ++) {
    cout << Ncr[i] << endl;
  }
  for (int i = 0; i <= K; i ++) {
    cout << Kcr[i] << endl;
  }*/
  if (K * (N - K) == 0) {
    int t = 0;
    if (K == N) t = 1;
    cout << t << endl;
    for (int i = 1; i < K; i ++) cout << 0 << endl;
    return 0;
  }
  cout << N - K + 1 << endl;
  for (int i = 1; i < K; i ++) {
    LL k = Ncr[i - 1] + Ncr[i] * 2 + Ncr[i + 1];
    k %= mod;
    k *= Kcr[i];
    k %= mod;
    cout << k << endl;
  }
}



Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(n);
    cini(x);
    cini(t);

    int cnt=(n+x-1)/x;
    cout<<cnt*t<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3568
import random
from operator import itemgetter
import sys
sys.setrecursionlimit(1000000)
ans=0

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

def gcd_all(l):
    rt=l.pop()
    for i in l:
        rt=gcd(i,rt)
    return rt
    
n=int(input())

g=[]

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

ans=0
d=a[-1]
m=a[-1]
mi=-1
k1=[]
flg=0
for i in range(n):
    gg=gcd(a[i],d)
    if gg<m:
        m=gg
        mi=i
ans=max(ans,gcd_all(a[:mi]+(a[mi+1:] if mi+1<n else [])))

d=a[0]
m=a[0]
mi=0
k1=[]
flg=0
for i in range(n):
    gg=gcd(a[i],d)
    if gg<m:
        m=gg
        mi=i
ans=max(ans,gcd_all(a[:mi]+(a[mi+1:] if mi+1<n else [])))

print(ans)

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

int main(void)
{
	int s;
	int s1, s2;
	
	scanf("%d", &s);

	s1 = s / 100;
	s2 = s - s1*100;

	if(1 > s1 || s1 > 12){
		if(1 > s2 || s2 > 12 ){
			printf("NA");
		} else {
			printf("YYMM");
		}
	} else {
		if(1 <= s2 && s2 <= 12){
			printf("AMBIGUOUS");
		} else {
			printf("MMYY");
		}
	}
		
	return 0;
}

Measured memory_bytes: 128