akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vs = V<string>;
using vd = V<double>; using vvi = V< V<int> >; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ini(N);
  if(__builtin_popcount(N)==1) die("No");
  out("Yes");
  vvi g(2*N+1);

  g[3].pb(N+1);
  for(int i=3;i<=N;i+=2){
    g[1].pb(i-1);
    g[i-1].pb(i);
    g[1].pb(i+N);
    g[i+N].pb(i+N-1);  
  }
  if(N%2==0){
    int x = N - 1;
    int y = N ^ x ^ 1;
    g[x + N].pb(N);
    g[y].pb(2*N);
  }
  

  rep1(i,N*2) each(j,g[i]) out(i,j);

}


Measured memory_bytes: 10616
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 22; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

ll dp[(1<<N)],n,a[N][N];

ll solve1(ll mask)
{
    ll one = __builtin_popcountll(mask);
    if(one==n)    return 1;
    ll &ans = dp[mask];
    if(ans!=-1)   return ans;
    ans = 0;
    for(ll i=0;i<n;i++)
    {
        if(a[one][i] && !(mask & (1<<i)))    ans = (ans + solve1(mask^(1<<i)) ) % MOD;
    }
    return ans;
}

void solve()
{
    cin >> n;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)   cin >> a[i][j];
    } 
    memset(dp,-1,sizeof(dp));
    ll ans = solve1(0);
    cout<<ans;
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

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

int main() {
    int n,k;
  cin>>n>>k;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);}
  
sort(vec.begin(), vec.end());
  
  int a=10000000000;
  for(int j=0;j<=n-k;j++){
    if(a>vec.at(j+k-1)-vec.at(j)){
      a=vec.at(j+k-1)-vec.at(j);}
  }
  
  cout << a<<endl;
     
      
}



Measured memory_bytes: 640
using System;

public class hello
{
    public static void Main()
    {
        var rect = 0; var hishi = 0;
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] line2 = line.Trim().Split(',');
            var a = int.Parse(line2[0]);
            var b = int.Parse(line2[1]);
            var c = int.Parse(line2[2]);
            if (a == b && a * a + b * b != c * c) hishi++;
            else if (a != b && a * a + b * b == c * c) rect++;
        }
        Console.WriteLine(rect);
        Console.WriteLine(hishi);
    }
}

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

int main() {
  string S;
  cin >> S;
    
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll S, W;
    cin >> S >> W;

    if(W>=S) _PR("unsafe");
    else _PR("safe");    


    return 0;
}

/*



*/

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

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

    if(a == b){
        cout << c << endl;
    }
    if(c == b){
        cout << a << endl;
    }
    if(a == c){
        cout << b << endl;
    }
}

Measured memory_bytes: 3616
n, m = map(int, input().split())
switches = []
for _ in range(m):
    switches.append(list(map(int, input().split()))[1:])
p = list(map(int, input().split()))

ans = 0
switchState = [0]*n


def dfs(i, tukeru):
    #print(i, tukeru)
    if(i == n):
        sumOfTento = 0
        for denkyu in range(m):
            sumOfswitch = 0
            for switch in switches[denkyu]:
                sumOfswitch += switchState[switch-1]
            if(sumOfswitch % 2 == p[denkyu]):
                sumOfTento += 1
        # print(switchState)
        if(sumOfTento == m):
            return 1
        else:
            return 0
    switchState[i] = tukeru
    return dfs(i+1, 0) + (dfs(i+1, 1) if i != n-1 else 0)


print(dfs(0, 0)+dfs(0, 1))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int i,n,t;
	cin >> n >> t;
	int a[n],b[n],c[n];
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	b[n-1] = a[n-1];
	for(i=0;i<n-1;i++){
		if(a[n-2-i]<b[n-1-i]){
			b[n-2-i] = b[n-1-i];
		}else{
			b[n-2-i] = a[n-2-i];
		}
	}
	
	for(i=0;i<n;i++){
		c[i] = b[i]-a[i];
	}
	sort(c,c+n);
	for(i=0;i<n;i++){
		if(c[i]==c[n-1]){
			cout << n-i << endl;
			return 0;
		}
	}
}
		
	
			
			
		

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

using namespace std;

int main() {
	int N, K;
  	cin >> N >> K;
  	vector<int> l(N);
  	for (int i = 0; i < N; ++i) cin >> l[i];
  	sort(l.begin(), l.end());
    cout << accumulate(l.end() - K, l.end(), 0) << endl;
}

Measured memory_bytes: 256
let init = function
  | [] -> raise (Failure "init")
  | x :: xs ->
      List.rev @@
      fst @@
      List.fold_left (fun (tr, x) y -> (x :: tr, y)) ([], x) xs

let () = Scanf.scanf "%d\n" @@ fun n ->
  let xys = Array.init n @@ fun i ->
    Scanf.scanf "%d %d\n" @@ fun x y -> x, y, i in
  Array.sort compare xys;
  let rec drop_until_ccw x y = function
    | ([] | [_]) as stack -> stack
    | ((x1, y1, _) :: (((x2, y2, _) :: _) as rest)) as stack ->
        if 0 < (x1 - x2) * (y - y1) - (y1 - y2) * (x - x1)
        then stack
        else drop_until_ccw x y rest in
  let convex =
    Array.of_list @@
    init @@
    let h, t =
      match
        Array.fold_left (fun stack (x, y, i) ->
          (x, y, i) :: drop_until_ccw x y stack) [] xys
      with
      | [] -> [], []
      | h :: t -> [h], t in
    Array.fold_right (fun (x, y, i) stack ->
      (x, y, i) :: drop_until_ccw x y stack) (Array.sub xys 0 (n - 1)) h @ t in
  let ps = Array.make n 0. in
  for i = 0 to Array.length convex - 1 do
    let (x1, y1, _) = convex.(i) in
    let (x2, y2, j) = convex.((i + 1) mod Array.length convex) in
    let (x3, y3, _) = convex.((i + 2) mod Array.length convex) in
    ps.(j) <-
      0.5 -. acos
        (float_of_int ((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2)) /.
         sqrt
           ((float_of_int (x1 - x2) ** 2. +. float_of_int (y1 - y2) ** 2.) *.
            (float_of_int (x3 - x2) ** 2. +. float_of_int (y3 - y2) ** 2.)))
      /. (8. *. atan 1.)
  done;
  Array.iter (Printf.printf "%.20f\n") ps


Measured memory_bytes: 512
import math
a,b,C=map(float,input().split())
print(f'{a*b/2*math.sin(math.radians(C)):.6f}')
print(f'{a+b+(a**2+b**2-2*a*b*math.cos(math.radians(C)))**0.5:.6f}')
print(f'{b*math.sin(math.radians(C)):.6f}')


Measured memory_bytes: 5720
#include <iostream>
        #include <vector>
        #include <algorithm>
        #include <cmath>
         
        int main() {
          
        	long long a, b, c;
            std::cin >> a >> b >> c;
          
          if( a + b + 2 * std::sqrt((long double)a * b) < c)
            std::cout << "Yes\n";
          else
            std::cout << "No\n";
        }

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

class Team
{
public:
	char name;
	int win,lose;
	Team(){
		win=lose=0;
	}
};

bool GreaterTeamCompare(const Team a,const Team b){
	if(a.win!=b.win) return a.win > b.win;
	else return a.lose < b.lose;
}

int main(void){
	int n;
	while(cin>>n,n){
		vector<Team> teams(n);
		for(int i=0;i<n;++i){
			char t; cin>>t;teams[i].name=t;
			for(int j=0,r;j<n-1;++j){
					cin>>r;
					if(r==0) ++teams[i].win;
					else if(r==1) ++teams[i].lose;
			}
		}
		sort(teams.begin(),teams.end(),GreaterTeamCompare);
		for(int i=0;i<n;++i){
			cout<<teams[i].name<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
struct Point {
    double x, y;
    bool operator < (const Point& p) const {
        if(x != p.x) return x < p.x;
        return y < p.y;
    }
};


double dist(double x, double y){
    return sqrt(x * x + y * y);
}
double dist(Point p, Point q){
    return dist(p.x - q.x, p.y - q.y);
}

int main(){
    int N;
    cin >> N;
    vector<Point> ps(N);
    const double th = M_PI * (0.25 + 0.5 * rand() / RAND_MAX);
    REP(i, N){
        double x, y;
        scanf("%lf %lf", &x, &y);
        ps[i].x = +cos(th) * x + sin(th) * y;
        ps[i].y = -sin(th) * x + cos(th) * y;
    }
    sort(ps.begin(), ps.end());
    double ans = dist(ps[0], ps[1]);
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N && ps[j].x - ps[i].x < ans; j++){
            ans = min(ans, dist(ps[i], ps[j]));
        }
    }
    printf("%.12f\n", ans);
    return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll N,M;
    Scll2(N,M);
    vector<pair<ll,ll> > d(N);
    Rep(i,N){
      Scll2( d[i].first , d[i].second );
    }
  
    sort( d.begin(), d.end() );
  
    ll ans = 0;
    for(int i = 0; M; i++ ){
      if(M<d[i].second){
        d[i].second = M;
      }
      M-=d[i].second;
      ans+=d[i].first*d[i].second;
    }
  
  
    

    printf("%llu\n", ans );


    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++)  cin >> a[i];
    sort(all(a),greater<int>());
    int n, r, tmp;
    n = a[0];
    tmp = n;
    if(n%2 == 0){
        for(int i=1; i<N; i++){
            if(abs(a[i] - n/2) <= tmp){
                r = a[i];
                tmp = abs(a[i] - n/2);
            }
        }
    }else{
        for(int i=1; i<N; i++){
            if(a[i] >= n/2+1 && (a[i] - n/2+1 <= tmp)){
                r = a[i];
                tmp = a[i] - (n/2+1);
            }else if(a[i] <= n/2 && n/2 - a[i] <= tmp){
                r = a[i];
                tmp = n/2 - a[i];
            }
        }
    }
    cout << n << " " << r << endl;
}

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

#define esp 1e-9

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int l,r;
	cin>>l>>r;
	long long int c=0;
	while(l<=r){
		c++;
		l*=2;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int h,m,s;

    cin >> s;

    h = s / 3600;
    s %= 3600;

    m =  s / 60;
    s %= 60;

    cout << h << ":" << m << ":" << s << endl; 
    
    return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	bool flag = false;
	int i = 0;
	while (i < n && s[i] == '0') i++;
	while (n > 0 && s[n - 1] == '0') n--;
	vector<int> cnt;
	auto solve = [&] () {
		int sz = cnt.size();
		vector<vector<int>> f(sz, vector<int>(3, 0));
		for (int i = 1; i < sz; i++) {
			f[i][0] = f[i - 1][2] + cnt[i - 1];
			if (i >= 2) f[i][0] = max((cnt[i - 2] == 1 ? f[i - 1][2] : f[i - 1][0] - 1) + cnt[i - 1], f[i][0]);
			f[i][1] = max(max((cnt[i - 1] == 1 ? f[i - 1][2] : f[i - 1][0]), f[i - 1][1] - 1), f[i - 1][2]) + cnt[i];
			f[i][2] = max(max(f[i - 1][0], f[i - 1][1]), f[i - 1][2]);
//			for (int k = 0; k < 3; k++) cout << f[i][k] << " \n"[k == 2];
		}
		return *max_element(f[sz - 1].begin(), f[sz - 1].end());
	};
	int ans = 0;
	while (i < n) {
		while (i < n) {
			int c1 = 0, c2 = 0;
			while (i < n && s[i] == '1') c1++, i++;
			while (i < n && s[i] == '0') c2++, i++;
			cnt.push_back(c1);
			if (c2 != 1) break;
		}
		ans += solve();
		cnt.clear();
	}
	cout << ans << endl;
	return 0;
}

/*
50
10101000010011011110001001111110000101010111100110
12
111011101111
11
11110111101
7
1101011
*/


Measured memory_bytes: 3876
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#define PI 3.14159265358979

using namespace std;

int main()
{
	double a, b, c, d, l, s, S;
	scanf("%lf%lf%lf", &a, &b, &c);
	d = sqrt(a*a + b*b - 2.0 * a*b*cos(c/180.0*PI));
	s = (a + b + d) / 2.0;
	S = sqrt(s*(s - a)*(s - b)*(s - d));
	printf("%.10f %.10f %.10f\n", S, a+b+d, S * 2.0 / a);
    return 0;
}



Measured memory_bytes: 3464
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <bitset>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;

ll pou(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x; x = x * x; a >>= 1;} return an;}

int main() {
  int n; cin>>n;
  ll a[n+1];
  for(int i=0;i<=n;i++) cin>>a[i];
  ll sm=0; for(int i=0;i<=n;i++) sm+=a[i];

  ll nw = 1, an = 0;
  for(ll i=0;i<=n;i++) {
    an += nw;
    nw -= a[i];
    sm -= a[i];
    //cout<<i<<" "<<an<<" "<<nw<<" "<<sm<<endl;
    if (nw<0) {
      cout<<-1<<endl;
      return 0;
    }
    nw = min(2*nw, sm);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  //string s;
  //map<string,int> s;
  //map<string,int> s{};
  //string res;
  //vector<int> a;
  
  cin >> n;
  long long sum = 0;
  //cout << s.at(0) << endl;
  //vector<int> s(n,0);
  //int tmp,res;
  //res = 0;
  //string res = "No";
  for(int i = 0;i<=n;i++){
    if((i%3 == 0) || (i%5 == 0)) {
      sum += 0;  
    }else {
      sum += i;
    }
  }
    
  cout << sum;
  
}

Measured memory_bytes: 3640
/**
*    created: 09.05.2020 15:51:46
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    string s;
    cin>>s;
    int a = 0, b = 0;
    rep(i,s.size()){
        if(s[i]=='1'){
            a++;
        }else{
            b++;
        }
    }
    cout << 2*min(a,b) << endl;
    
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

char S[3];
int cnt;

int main() {

	cin >> S;
	for (int i = 0; i < 1; i++) {
		if (S[i] == 'a' && S[i+1] == 'b' && S[i+2] == 'c') {
			cout << "Yes" << endl;
			return 0;
		}
		if (S[i] == 'a' && S[i + 1] == 'c' && S[i + 2] == 'b') {
			cout << "Yes" << endl;
			return 0;
		}
		if (S[i] == 'b' && S[i + 1] == 'a' && S[i + 2] == 'c') {
			cout << "Yes" << endl;
			return 0;
		}
		if (S[i] == 'b' && S[i + 1] == 'c' && S[i + 2] == 'a') {
			cout << "Yes" << endl;
			return 0;
		}
		if (S[i] == 'c' && S[i + 1] == 'a' && S[i + 2] == 'b') {
			cout << "Yes" << endl;
			return 0;
		}
		if (S[i] == 'c' && S[i + 1] == 'b' && S[i + 2] == 'a') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS; ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MX  3010
#define FF freopen("input.in","r",stdin); freopen("output.txt","w",stdout);
int main()
{
    //FF;
    IOS;
    int dp[MX][MX];
    string a,b;
    cin>>a>>b;
    int n=a.size();
    int m=b.size();
    memset(dp,0,sizeof dp);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i]==b[j])
            {
                dp[i+1][j+1]=dp[i][j]+1;
            }
            else
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }
    int idx=dp[n][m];
    string z="";
    int i=n-1;
    int j=m-1;
    while(idx>0)
    {
        if(a[i]==b[j])
        {
            z+=a[i];
            i--;
            j--;
            idx--;
        }
        else
        {
            if(dp[i+1][j]>dp[i][j+1])
            {
                //z+=a[j];
                j--;
            }
            else
                i--;
        }
    }
    reverse(z.begin(),z.end());
    cout<<z;
}



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

int main()
{
  int N;

  cin >> N;

  double X;
  string U;
  double ans = 0;

  for (int i = 0; i < N; i++)
  {
    cin >> X >> U;

    if (U == "JPY")
    {
      ans += X;
    }
    else
    {
      ans += X * 380000;
    }
  }

  cout << fixed << setprecision(8) << ans << endl;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)

# inputを高速化する。
input = sys.stdin.readline

# 入力
vacation = int(input())
lst_happiness = [list(map(int, input().split())) for i in range(vacation)]

# DPテーブル
# 最大化問題なので0で初期化
dp = [[0 for i in range(3)] for j in range(vacation+1)]

# dpの最大値を更新するための関数
def chmax(a, b):
    if a > b:
        return a
    else:
        return b

# メモ化再帰の関数
def rec(i):
    # DPの値が既に更新されている場合はその値を返す
    for j in range(3):
        if dp[i][j] > 0:
            break
        
        # 再帰の終了条件
        if i == 0:
            dp[i][j] = 0
            break
        
        # i-1 を再帰
        res = 0
        for k in range(3):
            if j == k:
                continue
            res = chmax(res, rec(i-1)[k] + lst_happiness[i-1][k])
            # 結果をメモする
            dp[i][j] = res
    
    return dp[i]

ans = rec(vacation)
ans = max(ans)
print(ans)

Measured memory_bytes: 133304
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
(n-k).times do |i|
  s = k + i
  bef = a[s - k]
  aft = a[s]
  if bef < aft
    puts 'Yes'
  else
    puts 'No'
  end
end

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

int main() {
	int N;
	cin >> N;
	int n = N;
	
	int S = 0;
	while (N) {
		S += N % 10;
		N /= 10;
	}

	if (n%S == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int n;
vector<int> a;

ll dp[2003][2003][2];
ll solve(int left,int right,int player){
    if(left==right)return player*a[left];
    if(dp[left][right][player]!=-1)return dp[left][right][player];
    
    ll maxi = -1;
    if( (!player&&a[left]>a[right]) || player ) maxi = max<ll>(maxi,solve((left+1)%n , right         , !player)+player*a[left]);
    if( (!player&&a[left]<a[right]) || player ) maxi = max<ll>(maxi,solve(left       , (right-1+n)%n , !player)+player*a[right]);

    return dp[left][right][player] = maxi;
}

int main(){
    rep(i,2003)rep(j,2003)rep(k,2)dp[i][j][k] = -1;
    cin>>n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    
    ll maxi = -1;
    rep(i,n) maxi = max(  maxi , solve((i+1)%n,(i-1+n)%n,0)+a[i]  );
    cout<<maxi<<endl;
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        a: String,
        b: String,
    }
    let mut vec_a: Vec<u64> = Vec::new();
    let mut vec_b: Vec<u64> = Vec::new();
    let mut count: u64 = 0;

    for a in a.bytes() {
        vec_a.push(a as u64);
    }

    for b in b.bytes() {
        vec_b.push(b as u64);
    }

    for index in 0..vec_a.len() {
        if !(vec_a[index] == vec_b[index]) {
            count += 1
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 6068
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int d,t,s;
	scanf("%d%d%d",&d,&t,&s);
	int cal=d%s==0?d/s:d/s+1;
	if(cal<=t)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
 } 

Measured memory_bytes: 3720
// ※注意t C++14でコンパイルしないとエラーがでます
// ダイクストラ法
// ALDS1_12_C http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_C&lang=jp
#include <bits/stdc++.h>
using namespace std;

struct Vertex {                       // 頂点の情報を構造体Vertexで表す
    vector<pair<int, int>> neighbor;  // 隣接する頂点とそこまでの距離
    bool fixed = false;               // この頂点が確定しているか否か
    int fixed_cost = 0;               // 確定したコスト（始点からの最短距離）
};

int main(void) {
    // ■■ 初期化・データの読み込み ■■ 　
    int n;
    cin >> n;
    Vertex vertexs[n];  // n個の頂点を用意する
    for(int i = 0; i < n; i++) {
        int v, k;  // v:頂点　　k:vに隣接する頂点の数
        cin >> v >> k;
        for(int j = 0; j < k; j++) {
            int vi, ci;
            cin >> vi >> ci;
            vertexs[v].neighbor.push_back(make_pair(ci, vi));  // 各頂点vに対して、（隣接する頂点までのコスト(距離) と　その隣接頂点 ）をneighbor に読み込む
        }
    }

    // ■■ ダイクストラ法を実行 ■■ 　
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;  // pair< 出発点からの頂点までのコスト , 頂点 > の値を持つpriority_queue　（greaterにしないと昇順にならない）
    que.push(make_pair(0, 0));
    while(!que.empty()) {
        int cost = que.top().first;
        int v = que.top().second;
        que.pop();
        if(vertexs[v].fixed == false) {
            vertexs[v].fixed = true;
            vertexs[v].fixed_cost = cost;
            for(int i = 0; i < int(vertexs[v].neighbor.size()); i++) {
                int vi = vertexs[v].neighbor[i].second;  // vi: 頂点vに隣接するi番目の頂点
                int ci = vertexs[v].neighbor[i].first;   // ci: 頂点vから頂点viまでのコスト
                if(vertexs[vi].fixed == false) {
                    que.push(make_pair(cost + ci, vi));
                }
            }
        }
    }

    for(int i = 0; i < n; i++) {
        cout << i << " " << vertexs[i].fixed_cost << endl;
    }
    return 0;
}



Measured memory_bytes: 9608
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end(),greater<ll>());
    if (k>n){
        k = n;
    }
    rep(i,k){
        vec[i] = 0;
    }
    ll ans = 0;
    rep(i,n){
        ans += vec[i];
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include <cmath>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef long long llong;

llong N, ans;

int main()
{
	cin >> N;
	ans = 0;
	for (llong i = 1; i * i < N; i++)
	{
		if (N % i == 0)
		{
			if(N % (N / i - 1) == N /  (N / i - 1))
				ans += N / i - 1;
		}
	}

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            int cnt = 1;
            //全体の差込口の数（使用済みが1）

            int ans = 0;

            while(cnt < B)
            {
                cnt = cnt - 1 + A;
                ans++;
            }
          
       

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


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

int main()
{
  int K;
  string S;
  cin>>K;
  cin>>S;
  if(S.size()<=K)
    cout<<S;
  else
  {
    for(int i=0;i<K;i++)
	    cout<<S[i];
    cout<<"...";
  }
}

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

int a[200010],b[200010];

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    int n=read();
    for(int i=1;i<=n;i++)
        a[i]=read();
        
    int res=0;
    
    for(int i=1;i<=n;i++){
        res^=a[i];
    }
    
    for(int i=1;i<=n;i++){
        cout<<(res^(a[i]))<<' ';
    }
    
    puts("");
    return 0;
}

Measured memory_bytes: 4364
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int n;
vector < int > v[300100];
bool vis[300100];

void DFS(int x){

    vis[x] = true;
    for(auto j : v[x]){
        if(!vis[j])  DFS(j);
    }
}

int main()
{

    int n , m;  cin >> n >> m;
    for(int i = 0;i<m;i++){
        int x,y,z;  cin >> x >> y >> z;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int Ans = 0;
    for(int i = 1;i<=n;i++){
        if(!vis[i]){
            Ans++;
            DFS(i);
        }
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 13568
n, m = gets.split(' ').map(&:to_i)

rn = 1
(2..n).each do |i|
  rn *= i
end
r1 = 2
(2..(n-2)).each do |i|
  r1 *= i
end
rn /= r1

rm = 1
(2..m).each do |i|
  rm *= i
end
r2 = 2
(2..(m-2)).each do |i|
  r2 *= i
end
rm /= r2

puts rn + rm


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

int main() {
  int n;
  cin >> n;
  map<int, string> mp;
  rep(i, 101) {
    mp[i] = "No";
  }
  rep (i, 10) {
    if (i == 0) continue;
    rep (j, 10) {
      if (j == 0) continue;
      mp[i * j] = "Yes";
    }
  }
  cout << mp[n] << endl;
  return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans;
    rep(j,2){
        if(j)ans.push_back('L');
        rep(i,ty-sy+j)ans.push_back('U');
        rep(i,tx-sx+j)ans.push_back('R');
        if(j)ans.push_back('D');
        if(j)ans.push_back('R');
        rep(i,ty-sy+j)ans.push_back('D');
        rep(i,tx-sx+j)ans.push_back('L');
        if(j)ans.push_back('U');
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
n = int(input())
r = [0]*n
for i in range(n):
    r[i] = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    b[i] = list(map(int, input().split()))


for i in range(1,n):
    for j in range(i-1,-1,-1):
        if r[j+1][1] < r[j][1]:
            r[j+1], r[j] = r[j], r[j+1] 

for i in range(1,n):
    for j in range(i-1,-1,-1):
        if b[j+1][0] < b[j][0]:
            b[j+1], b[j] = b[j], b[j+1]

ans = 0
for i in range(n-1, -1, -1):
    for j in range(n):
        if (r[i][0] < b[j][0]) and (r[i][1] < b[j][1]):
            ans += 1
            b[j][0] = -1
            break
print(ans)
            




Measured memory_bytes: 3064
L, N = map(int, input().split())

s = list(map(int, input().split()))

s2 = []
for i in range(N-1):
  s2.append(s[i+1] - s[i])
s2.append(s[0]+L - s[N-1])

s2 = sorted(s2)

print(sum(s2[:-1]))

Measured memory_bytes: 90828
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>=0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(n);
  vector<ll> a;
  rep(i, n){
    ll x;
    cin >> x;
    a.push_back(x - 1);
    a.push_back(x);
    a.push_back(x + 1);
  }

  map<ll, ll> m;

  rep(i, a.size()){
    m[a[i]]++;
  }

  ll res = 0;

  for(auto&& x:m){
    res = max(res, x.second);
  }
  cout << res;
  
}
#endif


Measured memory_bytes: 8940
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N;  cin >> N;
    vector<pair<ll,ll>> V(N);
    for(int i=0; i<N; i++){
        cin >> V[i].first >> V[i].second;
    }
    sort(V.begin(), V.end(), [](const pair<ll,ll> &a, const pair<ll,ll> &b){
        return a.second < b.second;
    });

    ll t = 0;
    for(int i=0; i<N; i++){
        t += V[i].first;
        if(t > V[i].second){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3328
N = int(input())
S = input()

if N%2==1: #奇数文字の時は無理
    print("No")
else:
    flag = True
    for i in range(N//2):
        if S[i] != S[i+(N//2)]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


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

int main() {
  int N;
  cin >> N;
  if (N%2 == 0){
    cout << N/2 <<endl;
  }
  else{
    cout << N/2 + 1 << endl;
  }
  
  //vector<int> vec = {2, 5, 2, 1};
  //sort(vec.begin(), vec.end());
  //reverse(vec.begin(), vec.end());
}


Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//


int32_t main()
{
  io;
  int k;
  cin>>k;
  queue<ll> q;
  for(int i = 1; i<= 9; i++)
    q.push(i);
  ll x;
  while(k--)
  {
    x = q.front();
    q.pop();
    if(x%10 != 0)
      q.push(x*10 + x%10 - 1);
    q.push(x*10 + x%10);
    if(x%10 != 9)
      q.push(x*10 + x%10 + 1);
  }
  cout<<x;
  return 0;
}


Measured memory_bytes: 4704
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  sort(c.begin(), c.end());
  ll k = 2;
  repr(i, n - 1) {
    c[i] = (c[i] * k) % mod;
    k++;
  }
  ll sum = 0;
  rep(i, n) sum = (sum + c[i]) % mod;
  sum = (sum * modpow(2, 2 * n - 2)) % mod;
  cout << sum << endl;








  
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll

string s;
int dp[1000000][4];

signed main(){
  cin>>s;

  dp[0][0]=1;
  rep(i,s.size()){
    rep(j,4){
      dp[i+1][j]+=dp[i][j];
    }
      if(s[i]=='A')
        dp[i+1][1]+=dp[i][0];
      if(s[i]=='B')
        dp[i+1][2]+=dp[i][1];
      if(s[i]=='C')
        dp[i+1][3]+=dp[i][2];
        if(s[i]=='?'){
          rep(j,4){
            dp[i+1][j]+=2*dp[i][j];
          }
          dp[i+1][1]+=dp[i][0];
          dp[i+1][2]+=dp[i][1];
          dp[i+1][3]+=dp[i][2];
        }
        rep(j,4){
          dp[i+1][j]%=M;
        }
    }
  
    cout<<dp[(int)s.size()][3]<<endl;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n;
int a[maxn],b[maxn],aa[maxn],bb[maxn],cc[maxn];

map<int,int> m,mm;

int p[maxn];
int cnt=0;

int Find(int x)
{
    return p[x]==x ? x : p[x]=Find(p[x]);
}

void Union(int x,int y)
{
    if (Find(x)==Find(y)) return;
    cnt++;
    p[Find(x)]=Find(y);
}

int32_t main()
{
    IOS
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i],aa[i]=a[i];
    for (int i=1;i<=n;i++) cin>>b[i],bb[i]=b[i];
    sort(aa+1,aa+n+1);
    sort(bb+1,bb+n+1);
    for (int i=1;i<=n;i++)
        if (aa[i]>bb[i]) return cout<<"No"<<endl,0;
    for (int i=1;i<=n;i++) cc[i]=upper_bound(aa+1,aa+n+1,bb[i])-aa-1;
    //for (int i=1;i<=n;i++) cout<<cc[i]<<" \n"[i==n];
    for (int i=1;i<=n;i++)
        if (cc[i]!=i) return cout<<"Yes"<<endl,0;
    for (int i=1;i<=n;i++) m[bb[i]]=i,mm[aa[i]]=i,p[i]=i;
    for (int i=1;i<=n;i++) Union(mm[a[i]],m[b[i]]);
    if (cnt==n-1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}



Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(void)
{
	long long count = 0;
	long long max = 0;
	long long N;

	cin >> N;

	vector<long long> H(N);

	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	for (int i = 0; i < N; i++)
	{
		count = 0;
		for (int j = i + 1; j < N; j++)
		{
			if (H[j - 1] >= H[j])
			{
				count++;
			}
			else
			{
				break;
			}
		}

		if (count > max)
		{
			max = count;
		}
		if (N - i < max)
		{
			break;
		}
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
using namespace std;
int a[6];
int main()
{
	int n, i = 0;
	int ans = 0;
	cin >> n;
	while (n > 0)
	{
		ans += n % 10;
		n = n / 10;
	}
	if (ans == 1)
		printf("10");
	else
		printf("%d", ans);
	return 0;
}

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

int n, m, o, x, y, add, ans;
char c;
string s;
int main() {
	cin >> n >> m;


	cout << n * m / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import product

H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]

ans = 0
for row in product([0, 1], repeat=H):
    for col in product([0, 1], repeat=W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if row[i] == 0 and col[j] == 0 and grid[i][j] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Measured memory_bytes: 9176
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int N=1250000;

inline unsigned long xor128() {
	static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
	unsigned long t=(x^(x<<11));
	x=y; y=z; z=w;
	return (w=((w>>19)^t^(t>>8)));
}

int D,c[26],s[200000][26],t[200000],T[200000],v,V,l[26];

int main(){
	scanf("%d",&D);
	for(int i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<D;i++){
		pair<int,int>mx={-1,-1};
		for(int j=0;j<26;j++){
			mx=max(mx,{s[i][j],j});
		}
		t[i]=mx.second;
	}
	for(int i=0;i<26;i++){
		l[i]=-1;
	}
	for(int i=0;i<D;i++){
		l[t[i]]=i;
		v+=s[i][t[i]];
		for(int j=0;j<26;j++){
			v-=c[j]*(i-l[j]);
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			if((xor128()&255)==0){
				T[j]=xor128()%26;
			}
			else{
				T[j]=t[j];
			}
		}
		for(int j=0;j<26;j++){
			l[j]=-1;
		}
		V=0;
		for(int j=0;j<D;j++){
			V-=c[T[j]]*(j-l[T[j]]-1)*(j-l[T[j]])/2;
			l[T[j]]=j;
			V+=s[j][T[j]];
		}
		for(int j=0;j<26;j++){
			V-=c[j]*(D-l[j]-1)*(D-l[j])/2;
		}
		if(V>=v){
			v=V;
			for(int j=0;j<D;j++){
				t[j]=T[j];
			}
		}
		/*
		else if((double)(N-i)/N/(v-V)*100>=(double)xor128()/4294967295){
			v=V;
			for(int j=0;j<D;j++){
				t[j]=T[j];
			}
		}
		* */
	}
	for(int i=0;i<D;i++){
		printf("%d\n",t[i]+1);
	}
}


Measured memory_bytes: 3808
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int a,b,t;
    cin >> a >> b >> t;

    long total = (t / a) * b;
    cout << total;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int T;
    cin>>T;
    rep(i,T){
        int N,M,A,B;
        cin>>N>>M>>A>>B;
        cout<<floor_sum(N,M,A,B)<<endl;
    }

    return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, dis[10][10];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < 10; ++ i) {
		for (int j = 0; j < 10; ++ j) {
			scanf("%d", &dis[i][j]);
		}
	}

	for (int k = 0; k < 10; ++ k) {
		for (int i = 0; i < 10; ++ i) {
			for (int j = 0; j < 10; ++ j) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++ i) {
		for (int j = 0; j < m; ++ j) {
			int x; scanf("%d", &x);
			if (x != -1) ans += dis[x][1];
		}
	}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long n = Long.parseLong(str[0]);
		long k = Long.parseLong(str[1]);

		if (k == 0) {
			System.out.println(n * n);
			return;
		}

		long ans = 0;

		for (int i = 1; i <= n; i++) {
			ans += (n / i) * Math.max(0, i - k);
			if (n % i != 0) {
				ans += Math.max(n % i - k + 1, 0);
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 32684
def solve(x, n, p_list):
    diff_min = 101
    res = 0
    for i in range(102):
        if i not in p_list:
            if abs(x - i) < diff_min:
                diff_min = abs(x - i)
                res = i
    return res


def main():
    x, n = map(int, input().split())
    p_list = list(map(int, input().split()))
    res = solve(x, n, p_list)
    print(res)


def test():
    assert solve(6, 5, [4, 7, 10, 6, 5]) == 8
    assert solve(10, 5, [4, 7, 10, 6, 5]) == 9
    assert solve(100, 0, []) == 100


if __name__ == "__main__":
    test()
    main()


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1e9+7;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) {
		cout << -1 << endl;
		return 0;

	}
	cout << a * b << endl;
	return 0;
}



Measured memory_bytes: 256