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

int main()
{
	int n = 0, c = 0, max = -100000, min = 100000, 
		mxi = 0, mii = 0;

	cin >> n;

	vector<int> a(n);
	vector<vector<int>> b;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > max) {
			max = a[i];
			mxi = i;
		}
		if (a[i] < min) {
			min = a[i];
			mii = i;
		}
				}

	if (abs(max) >= abs(min)) {
		for (int i = 0; i < n; i++) {
			if (a[i] < 0) {
				a[i] += max;
				b.push_back({mxi + 1 , i + 1 });
				c++;
			}
		}
		for (int i = 0; i < n - 1; i++) {
			if (a[i] > a[i + 1]) {
				a[i + 1] += a[i];
				b.push_back({i + 1 , i + 2});
				c++;
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				a[i] += min;
				b.push_back({ mii + 1, i + 1});
				c++;
			}
		}
		for (int i = n - 1; i > 0; i--) {
			if (a[i] < a[i - 1]) {
				a[i - 1] += a[i];
				b.push_back({ i + 1 , i });
				c++;
			}
		}
	}


	cout << c << endl;

	for (unsigned int i = 0; i < b.size(); i++)
		cout << b[i][0] << " " << b[i][1] << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0;i < n;i++)
			x[i] = s.nextInt();
		for(int i = 0;i < n;i++)
			y[i] = s.nextInt();
		double p1 = 0;
		double p2 = 0;
		double p3 = 0;
		double pInfi = 0;
		for(int i = 0;i < n;i++){
			int abs = Math.abs(x[i] - y[i]);
			p1 += abs;
			p2 += (double)(abs * abs);
			p3 += (double)(abs * abs * abs);
			if(pInfi < abs)pInfi = abs;
		}
		p2 = Math.sqrt(p2);
		p3 = Math.cbrt(p3);
		System.out.println(p1);
		System.out.println(p2);
		System.out.println(p3);
		System.out.println(pInfi);
		
	}
	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll f(ll a, ll n) {
  if (n == 0) return 1;
  ll x = f(a, n/2);
  x *= x;
  if (n % 2 == 1) x *= a;
  return x;
}

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

  for (int i = -2000; i <= 2000; i++) {
    for (int j = -2000; j <= 2000; j++) {
      ll a=f(i,5);
      ll b=f(j,5);
      if (x == (a-b)) {
        printf("%d %d\n",i,j);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3768
#include <cstdio>

int main()
{
  long long n;
  long long min = 1e16;
  scanf("%lld", &n);
  for (int i = 0; i < 5; ++i)
  {
    long long a;
    scanf("%lld", &a);
    if (min > a) min = a;
  }
  long long g = (n + min - 1) / min;
  printf("%lld\n", g + 4);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

int main() {
  int num = 700;
  std::string s;
  std::cin >> s;
  for (int i=0; i < s.length(); i++)
    if (s[i] == 'o')  num += 100;
  std::cout << num << std::endl;
  return 0;  
}

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

int main(){
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    //配列を使わない方がセグメント違反にならなかったりしていいかも
    int sw=100*A;
    int s=0;
    for(int i=0;i<101;i++){
        for(int j=0;j<101;j++){
            for(int k=0;k<101;k++){
                for(int l=0;l<101;l++){
                   int xw=100*(A*i+B*j);
                   int xs=C*k+D*l;
                if(xw+xs<=F){
                    if(100*xs<=xw*E){
                        if((double)xs/(double)(xw+xs)>(double)s/(double)sw){
                            sw=xw+xs;
                            s=xs;
                        }
                    }
                }
                }
            }
        }
    }
cout<<sw<<" "<<s<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int i, n,tmp;
	int count = 0;
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> tmp;
		if (i != tmp) {
			count++;
		}
	}
	if (count <= 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,a,b,s=0;
	scanf("%d%d%d",&n,&a,&b);
	s = n*a;
	if(s<b) printf("%d\n",s);
	else if(s>b) printf("%d\n",b);
	else printf("%d\n",b);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}



void solve(){
    ll len;
    cin >> len;
    double an = (1.0 * len)/(3.0);
    double res = an * an * an;
    cout << fixed << setprecision(10);
    g(res);
}
int main()
{

 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
   // cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 256
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
ll GetDigit(ll num){
    return to_string(num).length();
}
int main()
{
  ll N;
  cin >> N;

  ll MIN=INF;
  FOR(i,1,sqrt(N)+1){
    if(N%i!=0){
      continue;
    }else{
      MIN=min(MIN,max(GetDigit(i),GetDigit(N/i)));
    }
  }

  cout << MIN << endl;
}

Measured memory_bytes: 256
/* ex4_2
   offNaria */
#include <stdio.h>
#include <math.h>

double cosFormula(double a, double b, double c);

int main(void){
  double lengthOfMinuteHand, lengthOfHourHand, hour, minute;
  scanf("%lf %lf %lf %lf", &lengthOfMinuteHand, &lengthOfHourHand, &hour, &minute);
  double angle = 30 * hour + minute / 2 - 6 * minute; //時針は60分で30度＝1分で0.5度，分針は1分で6度動く
  angle = angle * M_PI / 180; //ラジアンに変換
  printf("%.11lf\n", cosFormula(lengthOfMinuteHand, lengthOfHourHand, angle)); //余弦定理
  return 0;
}

double cosFormula(double a, double b, double c){
  return sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(c)); //余弦定理
}


Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> p(N);
  for (int i = 0; i < N; i++){
    p[a[i] - 1] = i;
  }
  set<int> pos;
  pos.insert(-1);
  pos.insert(N);
  long long ans = 0;
  for (int i = 0; i < N; i++){
    long long L = p[i] - *prev(pos.lower_bound(p[i]));
    long long R = *(pos.lower_bound(p[i])) - p[i];
    ans += L * R * a[p[i]];
    pos.insert(p[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 14188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  if(n>=30)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 3636
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
typedef complex < double > P;
typedef vector< P > G;
const double EPS = 1e-8;
const double INF = 1e12;
double cross(const P& a,const P& b){ //外積
  return imag(conj(a) * b);
}
double dot(const P& a,const P& b){ // 内積
  return real(conj(a) * b);
}
#define curr(P,i) P[i]
#define next(P,i) P[(i+1)%P.size()]
bool conteins(const G& Q, const P& p){
  bool in = false;
  for(int i = 0 ; i < Q.size() ; i++ ){
    P a = curr(Q,i) - p, b = next(Q,i) - p;
    if(imag(a) > imag(b)) swap(a,b);
    if(imag(a) <= 0 && 0 < imag(b) && cross(a,b) < 0) in = !in;
    if(cross(a,b) == 0 && dot(a,b) <= 0) return true;
  }
  return in;
}

int main(){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    G g(3);
    g[0] = P(x1,y1);
    g[1] = P(x2,y2);
    g[2] = P(x3,y3);
    cout << (conteins(g,P(xp,yp)) ? "YES" : "NO") << endl;
  }
}

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

using namespace std;

const int maxn=105;

int n;
int a[maxn];

int main(){
	memset(a,0x3f,sizeof(a));
	cin>>n;
	for(int i=1;i<=n-1;i++)cin>>a[i];
	long long ans=0;
	for(int i=1;i<=n;i++){
		ans+=min(a[i-1],a[i]);
	}	
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
from collections import deque
N = int(input())
line = input().split()
Q = deque([])

flag = 0 if (N % 2 != 0) else 1
for i in range(N):
    if (i % 2 == 0):
        if (flag):
            Q.append(line[i])
        else:
            Q.appendleft(line[i])
    else:
        if (flag):
            Q.appendleft(line[i])
        else:
            Q.append(line[i])

print(' '.join(Q))


Measured memory_bytes: 115672
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[5000];

ll comb(ll a, ll b) {
  ll ans = frac[a];
  ll sh1, sh2;
  ll h = mod-2;
  ll two;
  while(h>0) {
    two = 1;
    sh1 = frac[b];
    sh2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      sh1 *= sh1;
      sh1 %= mod;
      sh2 *= sh2;
      sh2 %= mod;
    }
    h -= two;
    ans *= sh1*sh2%mod;
    ans %= mod;
  }
  return ans;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<5000;++i) frac[i] = frac[i-1]*i%mod;
  ll S;
  cin>>S;
  ll ans = 0;
  ll tmp;
  for(ll i=1;i<=S/3;++i) {
    tmp = S-3*i;
    ans += comb(tmp+i-1, i-1);
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3672
x,y=map(int,input().split())
z=(x+y)//3
n=abs(y-x)
r = (z-n)//2

def mod(x):
  return(x%(10**9+7))
a=1
for i in range(r,z):
  a=mod(a*(i+1))

b=1
for i in range(z-r):
  b=mod(b*(i+1))
if (x+y)%3!=0:
  a=0

c=pow(b,10**9+5,10**9+7)
print(mod(a*c))



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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    int L;
    vector<pint> edge[20];
    cin >> L;
    int M = 0, N = 0;
    while(L >= (1 << N)) N++;
    M = 2 * (N - 1);
    REP(i, N - 1){
        edge[i].push_back(pint(i + 1, 0));
        edge[i].push_back(pint(i + 1, 1 << i));
    }
    int W = 1 << (N - 1);
    for(int i = N - 2; i >= 0; i--){
        if(((L >> i) & 1) == 0) continue; 
        edge[i].push_back(pint(N - 1, W));
        W += 1 << i; M++;
    }
    cout << N << " " << M << endl;
    REP(i, N - 1){
        for(pint p : edge[i]){
            cout << i + 1 << " " << p.first + 1 << " " << p.second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//usr/bin/env go run $0 $@ ; exit

package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {
	n := nextInt()
	k := nextInt()
	s := nextInt()

	count := 0;
	for i := n; i >= 0 ; i-- {
		if(n % i == 0 && k % i ==0){
			count ++
		}
		if(s == count){
			Println(i)
			return
		}
	}

}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


Measured memory_bytes: 2816
#include<cstdio>
#include<algorithm>

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

using namespace std;

int dfs(int a,int b,int c){
	int res=0;
	if(a>=3) res=max(res,dfs(a-3,b,c)+1);
	if(b>=3) res=max(res,dfs(a,b-3,c)+1);
	if(c>=3) res=max(res,dfs(a,b,c-3)+1);
	if(a>0 && b>0 && c>0) res=max(res,dfs(a-1,b-1,c-1)+1);
	return res;
}

int main(){
	while(1){
		int n[3]={};
		rep(i,6){
			int a; scanf("%d",&a);
			n[i%3]+=a;
		}
		if(n[0]==0 && n[1]==0 && n[2]==0) break;

		int ans=0;
		int n0=min(min(n[0],n[1]),n[2]);
		rep(i,3){
			ans+=(n[i]-n0)/3;
			n[i]-=(n[i]-n0)/3*3;
		}
		ans+=max(n0-3,0);
		rep(i,3) n[i]-=max(n0-3,0);

		printf("%d\n",ans+dfs(n[0],n[1],n[2]));
	}

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

int main(){

    int N, K;
    int ans;

    cin >> N >> K;
    ans =  K * pow((K-1), (N-1)) ; 

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 512
# 参考 https://atcoder.jp/contests/abc170/submissions/14374757

n = gets.to_i
max = 0
nums = gets.split.each_with_object(Hash.new(0)) do |s, h|
	a = s.to_i
	h[a] += 1
	max = a if max < a
end

# dp
count = 0
nums.keys.sort.each do |a|
	next if nums[a] == 0
	count += 1 if nums[a] == 1
	a.step(max, a) { |b| nums[b] = 0 }
end

puts count

Measured memory_bytes: 66680
N = int(input())
A = [int(x) for x in input().split()]
l = [0]*N
ans = 0
for a in A:
    l[a-1] += 1
for j in l:
    ans += int(j*(j-1)/2)
for k in range(N):
    print(ans - l[A[k]-1] + 1)

Measured memory_bytes: 24748
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N;
	vector<int> V(N), W(N);
	for(int i=0; i<N; i++) cin >> V[i];
	sort(V.begin(), V.end());
	reverse(V.begin(), V.end());
	int sign = 1;
	for(int i=0; i<N; i++){
		W[i] = V[i] * sign;
		sign *= -1;
	}
	cout << accumulate(W.begin(), W.end(), 0) << endl;
	return 0;
}

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

using namespace std;

class Solution {
public:
	void solve() {
		long long a, v, b, w, t;
		cin >> a >> v >> b >> w >> t;
		if ((v - w) * t >= abs(b - a)) {
			cout << "YES"
					 << "\n";
		} else {
			cout << "NO"
					 << "\n";
		}
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 3;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE EVAL({cout << -1 << '\n'; exit(0);})
//------------------------------------------------------------------------------------------------------

const int N = 2e5 + 10;
int n;
string s;
int first_occ[26][N];
int dp[N], a[N];

int main() {
    cin >> s;
    n = s.size();
    REP(i, n) a[i] = s[i] - 'a';

    REP(c, 26) {
        first_occ[c][n] = n;
        for(int i = n-1; i >= 0; i--) {
            if(a[i] == c) {
                first_occ[c][i] = i;
            } else {
                first_occ[c][i] = first_occ[c][i+1];
            }
        }
    }

    dp[n] = 1;
    for(int i = n-1; i >= 0; i--) {
        int farthest = 0;
        REP(c, 26) {
            farthest = max(farthest, first_occ[c][i]);
        }
        dp[i] = 1 + dp[farthest+1];
    }

    string ans = "";

    for(int i = 0; i < n; ) {
        REP(c, 26) {
            if(dp[i] == 1 + dp[first_occ[c][i] + 1]) {
                ans += char('a' + c);
                i = first_occ[c][i] + 1;
                break;
            }
        }
    }

    cout << ans << '\n';
}






























Measured memory_bytes: 22548
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1000000007;
const int N = 100005;
const int M = 1000005;
 
#define ll                      long long int
#define loop(i,a,b)             for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)            for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)            for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)            for(int i=(int)a;i>=(int)b;--i)
#define pb                      push_back
#define F                       first
#define S                       second
#define mp                      make_pair
#define RALL(x)                 x.rbegin(),x.rend()
#define ALL(x)                     x.begin(),x.end()
#define MAX                      1e9
#define MIN                      -1e9
// #define max(x,y)                 (x>y)?x:y
// #define min(x,y)                 (x<y)?x:y
#define mid(l,r)                 (l+(r-l)>>1)
#define mina(a)                  *min_element(a.begin(), a.end())
#define maxa(a)                  *max_element(a.begin(), a.end())
#define PI                       acos(-1.0)

typedef  map<string,int>         msi;
typedef  map<int,int>            mii;
typedef  map<ll, ll>             mll;
typedef  map<char,int>           mci;
typedef  map<int,string>         mis;
typedef  pair<int,int>           pii;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef  vector<int>             vi;
typedef  vector<string>          vs;
typedef  vector<char>            vc;
typedef  vector<bool>            vb;
typedef  vector< pii >           vii;

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

    int n;
    cin>>n;
    int dp[3][100005];
    memset(dp, 0, sizeof(dp));
    vi a(n+1);
    vi b(n+1);
    vi c(n+1);
    loop(i,0,n)
    {
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    loop(i,1,n)
    {
        dp[0][i] = (a[i]+max(dp[1][i-1], dp[2][i-1]));
        // cout<<"dp[0][i] = a[i]+max(dp[1][i-1], dp[2][i-1])= "<<dp[0][i];
        dp[1][i] = b[i]+max(dp[2][i-1], dp[0][i-1]);
        dp[2][i] = c[i]+max(dp[0][i-1], dp[1][i-1]);
        // cout<<"i="<<i<<endl;
        // cout<<"ai bi ci = "<< a[i]<<b[i]<<c[i]<<endl;
        // cout<<dp[0][i]<<endl;
        // cout<<dp[1][i]<<endl;
        // cout<<dp[2][i]<<endl;
    }
    cout<<max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1])<<endl;

    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int N = 1e5+8;
int n,l,r;ll a[N],rev[N],fac[N],tmp,in[N];
ll qpow(ll a,int b)
{
	ll ret=1;
	while(b)
	{
		if(b&1)ret=(ret*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return ret;
}
ll C(int n,int m){if(m>n) return 0;return (((fac[n]*rev[m])%mod)*rev[n-m])%mod;}
int main()
{
	fac[0]=1;
	for(int i=1;i<N;++i)fac[i]=(fac[i-1]*i)%mod;
	rev[N-1]=qpow(fac[N-1],mod-2);
	for(int i=N-2;i>=0;--i)rev[i]=(rev[i+1]*(i+1))%mod;
	cin>>n;
	for(int i=1;i<=n+1;++i)cin>>a[i];
	for(int i=1;i<=n+1;++i)
	{
		if(in[a[i]]) {tmp=a[i];l=in[a[i]],r=i;break;}
		else	in[a[i]]=i;
	}
//	cout<<tmp<<" "<<l<<" "<<r;
	for(int i=1;i<=n+1;++i)
	{
		
		ll ans=(C(n+1,i)-C(l+n-r,i-1)+mod)%mod;
		cout<<ans<<endl;
	}
}

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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	int A[100001] = {};
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	int dp[100001] = {1};

	bool brock[100001];
	for (int i = 0; i < M; i++)
	{
		brock[A[i]] = true;
	}

	if (brock[1] == true) {
		dp[1] = 0;
	}
	else {
		dp[1] = 1;
	}
	for (int i = 2; i <= N; i++) {
		if (brock[i] == true) {
			continue;
		}
		dp[i] = dp[i - 1] + dp[i - 2];
		dp[i] %= (int)1e9+7;
	}
	cout << dp[N] << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  ll k;
  cin >> k;

  queue<ll> que;

  for (int i = 1; i < 10; i++) {
    que.push(i);
  }

  if (1 <= k && 9 >= k) {
    cout << k << endl;
    return 0;
  }
  int count = 0;

  while (1) {
    ll temp = que.front();
    count++;
    if (count == k) {
      cout << temp << endl;
      return 0;
    }
    que.pop();

    int mod = temp % 10;
    if (mod != 0) que.push(temp * 10 + mod - 1);
    que.push(temp * 10 + mod);
    if (mod != 9) que.push(temp * 10 + mod + 1);
  }
}

Measured memory_bytes: 5104
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

from heapq import heappop,heappush,heapify
def main1(a,b,c,k):
  ans=[]
  for x in a:
    for y in b:
      ans.append(-x-y)
  ans.sort()
  ans=ans[:k] if len(ans)>=k else ans+[0]*(k-len(ans))
  ans1=[]
  for z in c:
    for xy in ans:
      heappush(ans1,xy-z)
  for _ in range(k):
    print(-heappop(ans1))
main1(a,b,c,k)



Measured memory_bytes: 228968
#include <cstdio>

using namespace std;

long long ans;

int n,suma,sumb,a[10000010];

int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  int l=1,r=0;
  while(l<=n)
  {
    while((suma^a[r+1])==(sumb+a[r+1])&&r<n)
    {
      suma^=a[r+1];
      sumb+=a[r+1];
      r++;
    }
    ans=ans+(r-l+1);
    suma=suma^a[l];
    sumb=sumb-a[l];
    l++;
  }
  printf("%lld",ans);
}

Measured memory_bytes: 2496
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n = int(input())
points = set()
for _ in xrange(n):
    x,y = (int(x) for x in input().split())
    points.add((x,y))

if len(points) <= 1:
    print(0)
else:
    srt1 = sorted(points, key=lambda x: x[0] + x[1])
    x1,y1 = srt1[0]
    x2,y2 = srt1[-1]
    ans1 = abs(x1+y1 - (x2+y2))
    srt2 = sorted(points, key=lambda x: x[0] - x[1])
    x1,y1 = srt2[0]
    x2,y2 = srt2[-1]
    ans2 = abs((x1-y1) - (x2-y2))
    print(max(ans1, ans2))


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

const int N = 100 + 5;

int main ()
{
    string a;
    int n;
    cin >> n;
    cin >> a;
    int r = 0, g = 0;
    for (auto i: a) {
        if (i == 'R') ++r;
        else ++g;
    }
    if (r > g) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

vector<deque<int>> ans;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W; cin >> H >> W;
    int N; cin >> N;
    vector<int> v;
    rep(i, N) {
        int a; cin >> a; 
        v.push_back(a);
    }
    int idx = 0;

    rep(i, H) {
        deque<int> que;
        if (i % 2 == 0) {
            rep(j, W) {
                if(v[idx] == 0) idx++;
                v[idx]--;
                que.push_back(idx + 1);
            }
        } else {
            RREP(j, W - 1, 0) {
                if(v[idx] == 0) idx++;
                v[idx]--;
                que.push_front(idx + 1);
            }
        }
        ans.push_back(que);
    }
    rep(i, H) {
        rep(j, W) {
            if (j != 0) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int N, M;
int a[60], b[60];
bool g[60][60];
bool u[60];


void dfs(int v = 0){
	u[v] = true;
	rep(i, 0, N)
		if(g[v][i] && !u[i]) dfs(i);
}


int solve(){
	int ans = 0;
	rep(i, 0, M){
		fill(RNG(u, N), false);
		g[a[i]][b[i]] = g[b[i]][a[i]] = false;
		dfs();
		rep(i, 0, N)
			if(!u[i]) BRK(ans++);
		g[a[i]][b[i]] = g[b[i]][a[i]] = true;
	}
	return ans;
}


signed main(){
	cin >> N >> M;
	rep(i, 0, M){
		cin >> a[i] >> b[i], a[i]--, b[i]--;
		g[a[i]][b[i]] = g[b[i]][a[i]] = true;;
	}

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
//#include<math.h>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
//const ld M_PI=3.14159265358979323;

/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.count()/1e6 << endl;
*/
ll f(ll x,ll n){
    ll r=1;
    while(n){
        if(n%2==1)
        r=(r*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return r;

}

vector<ll> fact(2e5+10,1),ifact(2e5+10);
void build(){
    for(ll i=2;i<fact.size();i++)
    fact[i]=(i*fact[i-1])%mod;
    fr(i,0,fact.size()){
        ifact[i]=f(fact[i],mod-2);
    }
}
ll C(int n, int r){
    if(n<r)
    return 0;
    return (((fact[n]*ifact[r])%mod)*ifact[n-r])%mod;
}

/*ll C[1001][1001];
void build(){
    memset(C,0,sizeof(C));
    fr(i,0,1001)
    C[i][i]=1;
    fr(i,0,1001)
    C[i][0]=1;
    fr(i,2,1001){
        fr(j,1,i){
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
        }
    }
}*/
void solve(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k){
        cout<<s;
    }
    else{
        fr(i,0,k)
        cout<<s[i];
        cout<<"...";
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 6232
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int n, k;
	cin >> n >> k;
	int a[n], v[n];
	for(int i=0; i<n; i++){		
		cin >> a[i] >> v[i];
	}
	int dp[k+1];	
	dp[0]=0;
	ini(dp, 0);
	for(int i=0; i<n; i++){		
		for(int j=k; j>=a[i]; j--){
			dp[j] = max(dp[j], dp[j-a[i]]+v[i]);
		}
	}
	cout << dp[k] << endl;
 
	return 0;
}  

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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  for (int i = 1; i <= 9; i++) {
    for (int j = i; j <= 9; j++) {
      if (n == i * j) {
	 	 cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;

int n;
int a[200000];
map<int, long long> m;
long long ans = 0;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        m[a[i]]++;
    }

    for (auto a : m)
        ans += 1ll * a.second * (a.second - 1) / 2;

    for (int i = 0; i < n; i++)
        cout << ans - (m[a[i]] * (m[a[i]] - 1) - (m[a[i]] - 1) * (m[a[i]] - 2)) / 2 << "\n";

    return 0;
}


Measured memory_bytes: 10368
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {

            a[i] = in.nextInt();

        }
        
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        
        dp[1] = Math.abs(a[0] - a[1]);
        
        for (int i = 2; i < n; i++) {
            
            
            int ind ;
            for (int j = 1; j <= k; j++) {
                
                ind = i - j;
                if (ind == -1) {
                    break;
                }
                dp[i] = Math.min(dp[i], Math.abs(a[i] - a[ind]) + dp[ind]);
                
            }
            
            
        }
        
        
        System.out.println(dp[n - 1]);
        
        
        
    }

}


Measured memory_bytes: 50504
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
x = 0
j = 25
for i in a:
    x += b[i-1]
    if i - j == 1:
        x += c[j-1]
    j = i
print(x)

Measured memory_bytes: 9104
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const INF = 1e10;

struct Edge {
    int from, to;
    double cost;
    int limit;
}
 
void main() {
    int N, M;
    int S, G;
    Edge[][] Graph;

    bool input() {
        scanf("%d %d\n", &N, &M);
        if (N == 0 && M == 0) return false;
        scanf("%d %d\n", &S, &G);
        Graph = new Edge[][N + 1];
        foreach (i; 0 .. M) {
            int x, y, d, c;
            scanf("%d %d %d %d\n", &x, &y, &d, &c);
            Graph[x] ~= Edge(x, y, d, c);
            Graph[y] ~= Edge(y, x, d, c);
        }
        return true;
    }

    void solve() {
        auto D = new double[][][](N + 1, 31, 31);
        foreach (i; 0 .. N + 1) foreach (j; 0 .. 31) D[i][j][] = INF;
        struct P {
            int prev, v, city;
            double cost;
        }
        BinaryHeap!(Array!P, "a.cost > b.cost") PQ;
        PQ.insert(P(0, 0, S, 0));
        D[0][0][S] = 0;
        while (!PQ.empty) {
            P cur = PQ.front; PQ.removeFront;
            foreach (edge; Graph[cur.city]) {
                for (int d = -1; d <= 1; d++) {
                    int v = cur.v + d;
                    if (v <= 0 || v > edge.limit) continue;
                    if (edge.to == cur.prev) continue;
                    auto next = P(cur.city, v, edge.to, cur.cost + edge.cost / v);
                    if (D[next.prev][next.v][next.city] > next.cost) {
                        D[next.prev][next.v][next.city] = next.cost;
                        PQ.insert(next);
                    }
                }
            }
        }
        double Ans = INF;
        foreach (i; 0 .. N + 1) {
            Ans = min(Ans, D[i][1][G]);
        }
        if (Ans == INF) {
            writeln("unreachable");
        } else {
            writefln("%.10f", Ans);
        }
    }

    while (input) solve;
}

Measured memory_bytes: 2440
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ls = 0;//yuka
int rs = 0;

int main(){
	while(1){
		ll int cnt = 0;
		int n;
		cin >> n;
		if(n==0) break;
		string old ="";
		REP(i,n){
			string tmp;
			cin >> tmp;
			if((tmp=="lu"&&old=="ru")||(tmp=="ru"&&old=="lu")) cnt++;
			if((tmp=="ld"&&old=="rd")||(tmp=="rd"&&old=="ld")) cnt++;
			old = tmp;
		}
		cout << cnt << endl;
	}
}

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

int main(){
    long long x;
    cin >> x;

    long long syo = x / 11;
    long long amari = x % 11;

    if(amari == 0){
        printf("%lld\n", syo*2);
    }
    else if(1 <= amari and amari <= 6){
        printf("%lld\n", syo*2+1);
    }
    else if(7 <= amari and amari <= 10){
        printf("%lld\n", syo*2+2);
    }

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

const int MOD = 1000000007;

struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> val;
  for (int i = 1; i * i <= N; i++) {
    val.push_back(i);
    if (i != N / i) {
      val.push_back(N / i);
    }
  }
  sort(val.rbegin(), val.rend());
  vector<int> bar;
  for (int v : val) bar.push_back(N / (v + 1) + 1);
  bar.push_back(N+1);
  const int m = bar.size() - 1;
  vector<mint> dp0(m+1);
  dp0[0] = 1;
  rep(i, K) {
    vector<mint> dp1(m+1);
    rep(j, m) {
      dp1[0] += dp0[j];
      dp1[m - j] -= dp0[j];
    }
    rep(j, m) {
      dp1[j+1] += dp1[j];
      dp1[j] *= bar[j+1]-bar[j];
    }
    dp0 = dp1;
  }
  mint ans = 0;
  rep(j, m) {
    ans += dp0[j];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1404
#include <iostream>
#include <string>

int main() {
	std::string s;
	std::cin >> s;

	auto isOK = [](const std::string& s) {
		for (int i = 0; i < s.size() / 2; ++i)
			if (s[i] != s[s.size() - 1 - i])
				return false;

		return true;
	};

	std::cout << (isOK(s) && isOK(s.substr(0, s.size() / 2)) && isOK(s.substr(s.size() / 2 + 1, s.size() / 2)) ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    string s; cin >> s;
    int ans = MM;
    for(int i = 0; i < s.size()-2; i++){
        int tmp = (s[i] - '0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0';
        ans = min(ans, abs(tmp - 753));
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a, b, i, j;
string s;
int main() {
	cin>>a>>b>>s;
	for(i=0; s[i] && s[i]!='-'; i++);
	for(j=i+1; s[j] && s[j]!='-'; j++);
	cout<<(s[j]=='\0' && i==a && j-i-1==b ? "Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
int w,h,x,y,r;
scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if(0<=x-r)
    {
        if(x+r<=w)
        {
            if(0<=y-r)
            {
                if(y+r<=h)
                    printf("Yes\n");
               
                else
                    printf("No\n");
            }
            else
                printf("No\n");
            }

        else
            printf("No\n");
    }
    else
        printf("No\n");

}




Measured memory_bytes: 2104
s = list(input())
ans = "Yes"
for v in range(len(s)):
    if v % 2 == 0:
        if s[v] != "h":
            ans = "No"
            break
    else:
        if s[v] != "i":
            ans = "No"
            break
if len(s) % 2 ==1:
    ans = "No"
print(ans)

Measured memory_bytes: 3060
"use strict";

const main = arg => {
    const n = arg.split("\n")[0].split(" ")[0];
    const m = arg.split("\n")[0].split(" ")[1];
    
    console.log((n - 1) * (m - 1));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
import math

if __name__ == "__main__":
    # A(cm): 時針の長さ
    # B(cm): 分針の長さ
    # H(時): 時
    # M(分): 分
    A, B, H, M = map(int, input().split())

    angle_h = 2*math.pi * (60*H + M) / (12 * 60)
    angle_m = 2*math.pi * M / 60
    diff = abs(angle_h - angle_m)
    gamma = diff if diff < math.pi else 2*math.pi - diff
    ans = math.sqrt(A**2 + B**2 -2*A*B*math.cos(gamma))
    print(ans)

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

typedef long long ll;

main()
{
    string s;
    cin >> s;
    if(s.back() == 's'){
        cout << s + "es";
    }
    else{
        cout << s + "s";
    }



}





///promy_pompom
//hello world


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

int main() {
  string s;
  cin >> s;
  vector<int>ans(s.size(),0);
  s += 'x';
  bool rf = true;
  int rc = 1,lc = 1,vp;
  for(int i = 0;i < s.size()-1;i++){
    if(s[i] == s[i+1]){
      if(rf) rc++;
      else lc++;
    }
    else{
      if(rf){
        vp = i;
        rf = false;
        ans[vp] += (rc+1)/2;
        ans[vp+1] += rc/2;
        rc = 1;
      }
      else{
        rf = true;
        ans[vp] += lc/2;
        ans[vp+1] += (lc+1)/2;
        lc = 1;
      }
    }
  }
  for(int i = 0;i < s.size()-1;i++){
    cout << ans[i];
    if(i != s.size()-2) cout << " ";
    else cout << "" << endl;
  }
}


Measured memory_bytes: 1024
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
for i,num in enumerate(a):
    if num==1:
        break
j = i % (k-1)
ans = 0
if j>0:
    ii = i+(k-1-j)
    ans = i//(k-1) + 1
else:
    ii = i
    ans = i//(k-1)
ans += (n-1-ii) // (k-1) + int((n-1-ii)%(k-1)!=0)
print(ans)

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

int main(){
  int x;
  cin >> x;
  if(x>=30)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3620
N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = []
for i in range(M):
    b,c = map(int,input().split())
    BC.append([b,c])
BC.sort(key=lambda x:x[1], reverse=True)
# print(BC)

A.sort()

i = 0
j = 0
while i < N and j < M and BC[j][1] > A[i]:
    if BC[j][0] < 1:
        j += 1
        continue
    A[i] = BC[j][1]
    BC[j][0] -= 1
    i += 1

print(sum(A))

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

const int MAX_N = 1e5+1;
vector<int> graph[MAX_N], ans;
bool visited[MAX_N];

void dfs(int x) {
    visited[x] = true;
    ans.push_back(x);
    for (auto i : graph[x]) {
        if (!visited[i]) {
            dfs(i);
            break;
        }
    }
}

int main() {
    int N, M, a, b;
    cin >> N >> M;
    rep(i, M) {
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(1);
    reverse(ans.begin(), ans.end());
    ans.pop_back();
    dfs(1);

    cout << ans.size() << endl;
    rep(i, ans.size()) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 9720
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int i, j, tmp, ans;
  int N; cin >> N;
  vector <int>X(N,0);
  rep(i,N){cin >> X[i];}
  ans = 1000000000;

  FOR(i,1,101){
      tmp = 0;
      rep(j,N){
          tmp += (X[j]-i)*(X[j]-i);
      }
      if(tmp < ans){ans = tmp;}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int ans=0,count=0;
  for(int i=0;i<n-1;i++){
    if(h[i]>=h[i+1]){
      ++count;
    }else{
      count=0;
    }
    ans=max(ans,count); 
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640