akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS1A = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iN = sS1A.Length;
            string sS1R = new string(sS1A.Reverse().ToArray());
            string sS2A = sS1A.Substring(0, (iN - 1) / 2);
            string sS2R = new string(sS2A.Reverse().ToArray());
            string sS3A = sS1A.Substring((iN + 3) / 2 - 1);
            string sS3R = new string(sS3A.Reverse().ToArray());
            string sOut = "No";
            if (sS1A == sS1R && sS2A == sS2R && sS3A == sS3R) { sOut = "Yes"; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13396
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/

long long int N, Q;
long long int P[200005], Cl[200005], Cr[200005], R[200005];
long long int S[200005];

int main()
{
	cin >> N >> Q;
	long long int a, b;
	for (int i = 0; i < N-1; i++)
	{
		cin >> a >> b;
		a -= 1;
		b -= 1;
		P[b] = a;
		if (Cl[a] == 0)
		{
			Cl[a] = b;
		}
		else
		{
			R[Cr[a]] = b;
			Cr[a] = b;
		}
	}
	long long int p, x;
	for (int i = 0; i < Q; i++)
	{
		cin >> p >> x;
		p -= 1;
		S[p] += x;
	}

	cout << S[0] << " ";
	for (int i = 1; i < N; i++)
	{
		S[i] += S[P[i]];
		cout << S[i] << " ";
	}



	return 0;
}


Measured memory_bytes: 9984
//#include <bits/stdint.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
int main(){
    LL n,k;
    cin >> n >> k;
    VI h(n);
    REP(i,n) cin >> h[i];
    sort(ALL(h), greater<int>());
    LL ans =0;
    for(int i=k; i<n; i++){
      ans+=h[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//最大公約数
ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}
//最小公倍数
ll lcm(ll x, ll y) {
  return x/gcd(x, y)*y;
}
//素因数分解
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}
 
 
 ll mod=998244353;
 
int main() {
  ll n,k;
  cin>>n>>k;
  ll a[n];
  rep(i,n){
    cin>>a[i];
  }
 
  ll score=1;
  rep(i,k){
    score=score*a[k-1-i];
  }
 
  for(int i=k;i<n;i++){
    
    if(a[i]>a[i-k]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
 
 
 
}

Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{

    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n + 2);
    a[0] = 0;
    vector<ll> ruiseki(n + 2);
    ruiseki[0] = 0;
    for (int i = 1; i < n + 1; i++)
    {
        cin >> a[i];
        ruiseki[i] = ruiseki[i - 1] + abs(a[i - 1] - a[i]);
    }
    a[n + 1] = 0;
    ruiseki[n + 1] = ruiseki[n] + abs(a[n] - 0);
    for (int i = 1; i <= n; i++)
    {
        cout << ruiseki[i - 1] + ruiseki[n + 1] - ruiseki[i + 1] + abs(a[i - 1] - a[i + 1]) << endl;
    }
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,k,sum=0;
    cin >> n >> k;
    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        int a=abs(x[i]);
        int b=abs(k-x[i]);
        if(a>=b){
            sum += b*2;
        }
        if(a<b){
            sum += a*2;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, i, j = 0;
  int prime[10001];
  for(i = 2; i <= 10000; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= 10000; i++) {
    if(prime[i]) {
      for(j = 2 * i; j <= 10000; j += i) {
        prime[j] = 0;
      }
    }
  }
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    for(i=n ; i >= 5 ; i--){
      if(prime[i] && prime[i-2]) break;
    }
    printf("%d %d\n", i - 2, i);
  }
  return 0;
}

Measured memory_bytes: 1764
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int A = s.nextInt();
        int B = s.nextInt();
        int H = s.nextInt();
        int M = s.nextInt();

        double Hx = A * Math.cos(Math.toRadians(90 - 30 * H - (double) M / 2));
        double Hy = A * Math.sin(Math.toRadians(90 - 30 * H - (double) M / 2));

        double Mx = B * Math.cos(Math.toRadians(90 - 6 * M));
        double My = B * Math.sin(Math.toRadians(90 - 6 * M));

        double d = Math.sqrt((Hx - Mx) * (Hx - Mx) + (Hy - My) * (Hy - My));
        System.out.print(d);
    }
}

Measured memory_bytes: 35988
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	vector<int> y(n);
	for (int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	vector<int> vec;
	for (int i = 0; i < n; i++){
		vec.push_back(i);
	}
	double ans = 0;
	int coun = 0;
	do{
		for (int i = 0; i < n-1; i++){
			ans += sqrt((x[vec[i+1]]-x[vec[i]])*(x[vec[i+1]]-x[vec[i]]) + (y[vec[i+1]]-y[vec[i]])*(y[vec[i+1]]-y[vec[i]]));
		}
		coun++;
	}while(next_permutation(vec.begin(), vec.end()));
	cout << setprecision(10) << ans/coun << endl;
	return 0;
}

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

using ll = long long;

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  vector<vector<ll>> a(n, vector<ll>(m));
  vector<vector<ll>> b(m, vector<ll>(l));
  vector<vector<ll>> c(n, vector<ll>(l));
  for (int i{}; i < n; ++i) {
    for (int k{}; k < m; ++k) {
      cin >> a[i][k];
    }
  }
  for (int k{}; k < m; ++k) {
    for (int j{}; j < l; ++j) {
      cin >> b[k][j];
    }
  }

  for (int i{}; i < n; ++i) {
    for (int j{}; j < l; ++j) {
      for (int k{}; k < m; ++k) {
        c[i][j] += a[i][k] * b[k][j];
      }
      if (j) cout << ' ';
      cout << c[i][j];
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3268
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long h, w;
	cin >> h >> w;

	if (h == 1LL || w == 1LL) {
		cout << 1 << endl;
		return 0;
	}

	long long ans = (h * w + 1) / 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)


ll check(ll n){
    ll p = sqrtl(n);
    if(p*p==n)  return p;
    return p+1;
}

int main(){
int t,tc = 0;

ll s;
cin>>s;
ll x2,y2,x3,y3;
x2 = check(s);
y3 = x2;
x3 = 1;
y2 = x2*x2-s;
cout<<"0 0 "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin>>S;
    N = S.size();
    int ans = INF;
    REP(i,N-1){
        if(S[i]!=S[i+1]) chmin(ans,max(i+1,N-i-1));
    }
    if(ans == INF) ans = N;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#define int long long 
#define mod 1000000007
int a[110],n;
struct node{
	int x,y;
};
int quickpow(int x,int y){
	if(y==0)return 1;
	if(y==1)return x;
	if(y%2==0)return quickpow(x*x%mod,y/2);
	if(y%2==1)return quickpow(x*x%mod,y/2)*x%mod;
}
node calc(int l,int r,int lim){
	int minn=0x3f3f3f3f3f3f3f3f,cnt=0;
	node ans;
	for(int i=l;i<=r;i++)
		if(a[i]<minn)minn=a[i],cnt=1;
		else if(a[i]==minn)cnt++;
	if(cnt==r-l+1){
		ans.x=(quickpow(2,r-l+1)-2+mod)%mod;
		ans.y=quickpow(2,minn-lim-1);
		return ans;
	}
	int s0=1,s1=1,last=0;
	for(int i=l;i<=r+1;i++){
		if(!last&&a[i]>minn)last=i;
		else if(last&&(i==r+1||a[i]==minn)){
			node Ans=calc(last,i-1,minn);
			(s0*=(Ans.x+4*Ans.y%mod)%mod)%=mod;
			(s1*=Ans.y*2%mod)%=mod;
			last=0;
		}
	}
	s0=(s0+mod-s1)%mod;
	ans.x=(s0*quickpow(2,cnt)%mod+s1*(quickpow(2,cnt)-2+mod)%mod)%mod;
	ans.y=s1*quickpow(2,minn-lim-1)%mod;
	return ans;
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	if(n==1){
		printf("%lld",quickpow(2,a[1]));
		return 0;
	}
	int ans=1;
	for(int i=1;i<=n;i++)
		if(a[i]>a[i-1]&&a[i]>a[i+1]){
			(ans*=quickpow(2,a[i]-std::max(a[i+1],a[i-1])))%=mod;
			a[i]=std::max(a[i+1],a[i-1]);
		}
	node Ans=calc(1,n,0);
	printf("%lld\n",ans*(Ans.x+2*Ans.y%mod)%mod);
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

char trans(int x) {
	if (0 <= x && x <= 9) return char('0' + x);
	x -= 10;
	return char('A' + x);
}

int main() {
	int N, M, Q;
	
	while (cin >> N >> M >> Q, N) {
		vector< set< char > > cnd(M);
		vector< bool > on(N, false);
		
		for_(i,0,M) for_(x,0,N) cnd[i].insert(trans(x));
		
		for_(i,0,Q) {
			string S, B; cin >> S >> B;
			
			for_(j,0,N) if (S[j] == '1') on[j] = !on[j];
			
			for_(j,0,M) {
				if (B[j] == '1') {
					for_(k,0,N) if (!on[k]) cnd[j].erase(trans(k));
				} else {
					for_(k,0,N) if (on[k]) cnd[j].erase(trans(k));
				}
			}
		}
		
		for_(i,0,M) {
			if (cnd[i].size() == 1) cout << *cnd[i].begin();
			else cout << "?";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define is_set(num, bin) ((1 << bin) & num) >> bin
using namespace std;
int main(){
  string S;
  cin >> S;
  long int bit, tmp, total = 0, N = S.length(), max_bit = pow(2, S.length() - 1);
  for(bit = 0; bit < max_bit; bit++){
    tmp = int(S[0]) - 48;
    for(int i = 0; i < N - 1; i++){
      if(is_set(bit, i) == 0){
        tmp = tmp * 10 + int(S[i + 1]) - 48;
      }else{
        total += tmp;
        tmp = int(S[i + 1]) - 48;
      }
    }
    total += tmp;
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n;cin>>n;
    if(n>=30) cout<<"Yes\n";
    else cout<<"No\n";
}

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

    solve();
    return 0;
}

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

int ans[10000005];

int main()
{
    int n;
    cin >> n;
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
            }
        }
    }
    for(int i = 1; i <= n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 3824
#include<iostream>
using namespace std;
int main() {
	int a,b;
	int ans[11];
	while (1) {
		cin >> a;
		if (a == 0) {
			goto a;
		}
		for (int i = 1; i <= 7; i++) {
			ans[i] = 0;
		}
		for (int i = 1; i <= a; i++) {
			cin >> b;
			if (b < 10) {
				ans[1] += 1;
			}
			else {
				if (b < 20) {
					ans[2] += 1;
				}
				else {
					if (b < 30) {
						ans[3] += 1;
					}
					else {
						if (b < 40) {
							ans[4] += 1;
						}
						else {
							if (b < 50) {
								ans[5] += 1;
							}
							else {
								if (b < 60) {
									ans[6] += 1;
								}
								else {
									ans[7] += 1;
								}
							}
						}
					}
				}
			}
		}
		for (int i = 1; i <= 7; i++) {
			cout << ans[i] << endl;
		}
	}
a:;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    
    
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    else if (s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

int n;

int main(void) {
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++ i) if (i & 1){
		int cur = 0, tmp = i;
		for (int j = 1; j <= i; ++ j) if (i % j == 0) ++ cur;
		if (cur == 8) ++ ans;
	}
	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 ConsoleApp64 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int D = st[0];
            int X = st[1];

            var A = new int[N];

            for (int i = 0; i < N; i++) {
                A[i] = int.Parse(Console.ReadLine());
            }

            int ans = 0;

            for (int i = 0; i < N; i++) {
                ans += (D - 1) / A[i] + 1;
            }

            Console.WriteLine(ans + X);
        }
    }
}


Measured memory_bytes: 13268
program name
    implicit none
    integer(8):: a,b,c,na
    logical:: apa(0:99)
    read*, a,b,c
    apa(:) = .false.
    na = a
    do
        if (mod(na,b) == c) then
            print*, 'YES'
            stop
        else
            if (apa(mod(na,b))) then
                print*, 'NO'
                stop
            end if
            apa(mod(na,b)) = .true.
            na=na+a
        end if
    end do
end program name

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
maxnow = A[0]
fumidaisum = 0
for i in range(1,N):
    if A[i]<maxnow:
        fumidaisum += -A[i]+maxnow
    elif A[i]>maxnow:
        maxnow = A[i]

print(fumidaisum)

Measured memory_bytes: 94100
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std;
int main(){
    bool who = true;
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0){
        if(who){
            c -= b;
        }else{
            a -= d;
        }
        who = !who;
    }
    if(a<=0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie   
    int n ;
    cin >> n ;
    for(int i=1000; i<=100000; i+=1000) {
        if(i >= n) {
            cout << i-n << "\n" ;
            return 0 ;
        }
    }
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

int gcd(int a,int 
b){
    if(a==0) return b;
    return gcd(b%a,a);
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
#define repM1(i, n) for(ll i = (ll)(n - 1); i > 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);

	ll a;
	cin >> a;

	cout << ll(a + pow(a, 2) + pow(a, 3)) << endl;
	return 0;
}

Measured memory_bytes: 4060
#include <iostream>                                                                
#include <vector>                                                                  
#include <array>                                                                   
#include <set>                                                                     
#include <cmath>                                                                   
#include <string>                                                                  
#include <queue>                                                                   
#include <list>                                                                    
#include <stack>                                                                   
#include <unordered_map>                                                           
#include <algorithm>                                                               
#include <functional>                                                              
#include <iomanip> // std::std::setprecision(X)                                    
#include <limits>  //std::numeric_limits<int>::max(), min()                        
                                                                                   
typedef long long ll;                                                              
                                                                                   
int main (void) {                                                                  
                                                                                   
  std::string S; std::cin >> S;                                                    
                                                                                   
  int ans = 0;                                                                     
  std::stack<char> L;                                                              
  for(unsigned int i=0; i<S.size(); i++) {                                         
    if ( L.empty() || L.top() == S[i] ) L.push(S[i]);                              
    else {                                                                         
      L.pop();                                                                     
      ans += 2;                                                                    
    }                                                                              
  }                                                                                
                                                                                   
  std::cout << ans << std::endl;                                                   
  return 0;                                                                        
}                                                                                  

Measured memory_bytes: 512
#include<stdio.h>

int main(void){
    int K,N,i;
    scanf("%d %d",&K,&N);
    int A[N];
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    int max=K-A[N-1]+A[0];
    for(i=1;i<N;i++){
        if(max<A[i]-A[i-1]){
            max=A[i]-A[i-1];
        }
    }
    printf("%d\n",K-max);
    return 0;
}

Measured memory_bytes: 896
#include <cstdio>

const int N = 60, mod = 1e9 + 7;
int n, i, f;
char a[N], b[N];
long long p;

int main()
{
	scanf("%d %s %s", &n, a + 1, b + 1);
	if (a[1] == b[1]) i = 2, p = 3; else
	i = 3, p = 6, f = true;
	for (; i <= n; ) if (a[i] == b[i])
	{
		if (f) f = false; else
		p = p * 2 % mod;
		i++;
	} else
	{
		if (!f) p = p * 2 % mod; else
		p = p * 3 % mod;
		i += 2; f = true;
	}
	printf("%lld", p);
	return 0;
}

Measured memory_bytes: 128
N, W = map(int, input().split())
wvlist = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
    for sum_w in range(W + 1):
        if sum_w >= wvlist[i][0]:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - wvlist[i][0]] + wvlist[i][1])
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
print(dp[N][W])


Measured memory_bytes: 121068
// ABCABC078B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;

	cout << (X - Z) / (Y + Z) << endl;

	return 0;
}


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

int main() {
  string A;
  cin >> A;
  for(int i=0;i<3;i++){
    if(A.at(i)=='1'){
      A.at(i)='9';
    }
    else{
      A.at(i)='1';
    }
  }
  cout << A << endl;
}

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

//#define DEBUG

using namespace std;

int main(){
    string ans="No";
    string s, t;

    cin >> s >> t;

    for(int i=0; i<t.length(); i++){

#ifdef DEBUG
        cout << s << endl;
        cout << t << endl;
#endif

        if(s == t){
            ans = "Yes";
            break;
        }
        t.insert(t.begin(), t.back());
        t.pop_back();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

bool cmp(pii &a, pii &b){
    return a.second > b.second;
}

int main(){
    int i,tmp,res;
    pii t[5];
    forN(i,5){
        cin >> t[i].first;
        t[i].second = (t[i].first -1) % 10;
    }
    sort(&t[0],&t[5],cmp);
    res = 0;
    forN(i,4){
        res += (t[i].first +9)/10;
    }
    res *= 10;
    res += t[4].first;
    cout << res << endl;
}

Measured memory_bytes: 384
using System;
public class FoF {
    public static void Main() {
        string read = Console.ReadLine();
        int N = int.Parse(read);
        int[] index = new int[N];
        for (int i = 2; i <= N; i++) {
            int id = i;
            for (int j = 2; j <= id; j++) {
                while (id % j == 0) {
                    index[j - 1]++;
                    id /= j;
                }
            }
        }
        long patern = 1;
        /*int ind = 0;
        patern [0]= 1;*/
        for (int i = 1; i < N; i++) {
            patern *= (index[i] + 1);
            patern %= (int)(Math.Pow(10, 9) + 7);
            /*if (patern / (Math.Pow(10, 9) + 7) >= 1) {
                patern %= (int)(Math.Pow(10, 9) + 7);
                ind++;
                patern[ind] = 1;
            }*/
        }
        /*long endpat=0;
        for (int i = 0; i < 1000; i++) {
            endpat += patern[i];
            if (endpat >= Math.Pow(10, 9) + 7) {
                endpat -= (int)Math.Pow(10, 9) + 7;
            }
        }
        Console.WriteLine(endpat);*/
        Console.WriteLine(patern);
        /*int index = 0;
        int patern = 1;
        for (int i = 2; i <= N; i++) {
            while (N % i == 0) {
                index++;
                N /= i;
            }
            patern *= (index + 1);
            index = 0;
            //Console.WriteLine(i);
        }*/

        //Console.WriteLine(patern);
    }
}

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

int main(){
    int H, W;
    vector<pair<int, int> > d;
    while (true)
    {
        cin >> H >> W;
        if(H==0 && W==0) break;
        else d.push_back(make_pair(H, W));
    }

    for (int i = 0; i < d.size(); i++)
    {
        for (int j = 0; j < d.at(i).first; j++)
        {
            for (int k = 0; k < d.at(i).second; k++)
            {
                if(j==0 || j==d.at(i).first-1 || k==0 || k==d.at(i).second-1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int K,A,B;
    scanf("%d%d%d",&K,&A,&B);
    if(A%K==0||B%K==0)
       printf("OK\n");
    else if(A/K!=B/K)
       printf("OK\n");
    else
       printf("NG\n");
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define MAXN 100005
using namespace std;
int bit[MAXN];
int n;

void init(int n) {
  for (int i=1; i<=n; i++) {
    bit[i]=0;
  }
}
void add(int s,int t,int x) {
  while (t) {
    bit[t]+=x;
    t-=t&(-t);
  }
  s--;
  while (s) {
    bit[s]+=(-x);
    s-=s&(-s);
  }
}
int get(int i) {
  int ans=0;
  while (i<=n) {
    ans+=bit[i];
    i+=i&(-i);
  }
  return ans;
}
int main() {
  int q;
  cin >> n >> q;
  init(n);
  while (q--) {
    int f;
    cin >> f;
    if (f==0) {
      int s, t, x;
      cin >> s >> t >> x;
      add(s,t,x);
    } else {
      int i;
      cin >> i;
      printf("%d\n",get(i));
    }
  }
  return 0;
}

Measured memory_bytes: 3556
#include<stdio.h>
#include<string.h>
#define MYSTRINGMAX 200000
#define SIZE MYSTRINGMAX + 2

int main(void) {
	char s[SIZE], t[SIZE], c1, c2;
	int flag = 0, i, j;
	fgets(s, SIZE, stdin);
	fgets(t, SIZE, stdin);
	int length = strlen(s);
	for (i = 0; i < length; i++) {
		if (s[i] != t[i]) {
			c1 = s[i];
			c2 = t[i];
			for (j = 0; j < length; j++) {
				if (s[j] == c2 || s[j] == c1) {
					if (j < i) {
						flag = 1;
						break;
					}
					if (s[j] == c1) {
						s[j] = c2;
					}
					else {
						s[j] = c1;
					}
				}
			}
			if (flag == 1) {
				printf("No\n");
				return 0;
			}
		}
		if (flag == 1) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

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

namespace Spreadsheet
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] input = Console.ReadLine().Split(' ');
            int r = int.Parse(input[0]);
            int c = int.Parse(input[1]);
            int[,] sheet = new int[r, c];
            for (int i = 0; i < r; ++i)
            {
                input = Console.ReadLine().Split(' ');
                for (int j = 0; j < c; ++j)
                {
                    sheet[i, j] = int.Parse(input[j]);
                }
            }

            for (int i = 0; i < r; ++i)
            {
                int sum = 0;
                for (int j = 0; j < c; ++j)
                {
                    Console.Write("{0} ", sheet[i, j]);
                    sum += sheet[i,j];
                }
                Console.WriteLine("{0}", sum);
            }

            int sumsum = 0;
            for (int i = 0; i < c; ++i)
            {
                int sum = 0;
                for (int j = 0; j < r; ++j)
                {
                    sum += sheet[j, i];
                }
                Console.Write("{0} ", sum);
                sumsum += sum;
            }
            Console.WriteLine("{0}",sumsum);
        }
    }
}


Measured memory_bytes: 9252
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MAX_N 55
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vv = vector<vector<ll>>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
vv a(MAX_N,vector<ll>(MAX_N));
vv ca(MAX_N,vector<ll>(MAX_N));
ll n,k;
vv mul(const vv &a,const vv &b){
  vv c(n,vector<ll>(n,0ll));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        c[i][j] += a[i][k]*b[k][j];
        c[i][j] %= MOD;
      }
    }
  }
  return c;
}
vv matrix_pow(const vv &x,ll k){
  if(k==1){
    return a;
  }
  vv b = matrix_pow(x,k/2);
  vv c = mul(b,b);
  if(k%2==0){
    return c;
  }else{
    return mul(a,c);
  }
}
signed main(){
  init_io();
  cin >> n >> k;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> a[i][j];
    }
  }
  vv a = matrix_pow(a,k);
  ll ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      ans += a[i][j];
      ans %= MOD;
    }
  }
  cout << ans << endl;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll comb(ll a, ll b);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n;
    cin >> n;
    if (n / 10 == 9 || n % 10 == 9)
    {
        c("Yes");
    }
    else
    {
        c("No");
    }
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] s = {0,0,0,0,0,0,0,0,0,0,0,0,0};
		int[] h = {0,0,0,0,0,0,0,0,0,0,0,0,0};
		int[] c = {0,0,0,0,0,0,0,0,0,0,0,0,0};
		int[] d = {0,0,0,0,0,0,0,0,0,0,0,0,0};
		for (int i = 0; i < n; i++) {
			String[] card = br.readLine().split(" ");
			switch (card[0]) {
				case "S":
					change(Integer.parseInt(card[1]), s);
					break;
				case "H":
					change(Integer.parseInt(card[1]), h);
					break;
				case "C":
					change(Integer.parseInt(card[1]), c);
					break;
				case "D":
					change(Integer.parseInt(card[1]), d);
					break;
			}
		}
		print("S", s);
		print("H", h);
		print("C", c);
		print("D", d);
	}

	private static void print(String str, int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (array[i] == 0) {
				System.out.println(str + " " + (i + 1));
			}
		}
	}

	private static void change(int n, int[] array) {
		array[n - 1] = 1;
	}
}

Measured memory_bytes: 24240
#include<stdio.h>

int main(){
int a;scanf("%d",&a);
int L=a/100;
int R=a%100;
if(1<=L&&L<=12){
if(1<=R&&R<=12)printf("AMBIGUOUS\n");
else printf("MMYY\n");
}else{
if(1<=R&&R<=12)printf("YYMM\n");
else printf("NA\n");
}
}


Measured memory_bytes: 128
n = int(input())
mod = 10**9 + 7
import math

def cnt(n, i):
    if i == 1:
        return 1
    else:
        l = n - 3*i
        m = i-1
        return  math.factorial(l + m)//(math.factorial(l)*math.factorial(m))
        

if n == 2 or n == 1:
    print(0)
    exit()
if n == 3:
    print(1)
    exit()
else:
    ans = 0
    iter = n // 3
    for i in range(1, iter + 1):
        if i*3 <= n:
            ans += cnt(n, i)%mod
        else:
            continue
        
print(ans % mod)

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

int main(){
    int n;
    long long cnt = 0;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);
    for(int i=0; i<n+1; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }

    for(int i=0; i<n; i++){
        if(b[i] <= a[i]){
            cnt += b[i];
        }else{
            cnt += a[i];
            b[i] -= a[i];
            if(b[i] <= a[i+1]){
                cnt += b[i];
                a[i+1] -= b[i];
            }else{
                cnt += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
const int mod=(int)1e9+7;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    int n,f=0;
    deque<int>v;
    cin>>n;
    if(n%2==0) f=1;
    for(int x=1;x<=n;x++){
        int i;
        cin>>i;
        if(f){
            if(x%2==0){
                v.push_front(i);
            }
            else v.push_back(i);
        }
        else{
            if(x%2==0) v.push_back(i);
            else v.push_front(i);
        }
    }
    for(int x=0;x<n;x++) cout<<v[x]<<" ";
	return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
int main(){
  int a,b,c,e,f,g;
  cin >> a >> b >> c;
  e = abs(a-b);
  f = abs(b-c);
  g = abs(c-a);
  cout << min(e+f,min(e+g,f+g)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, m, i;
	int field[1000]={0}, dice[1000]={0};
	
	while(1){
		scanf("%d %d", &n, &m);
		if(n==0 && m==0) break;
		
		for(i=0; i<n; i++)
			scanf(" %d", &field[i]);
		for(i=0; i<m; i++)
			scanf(" %d", &dice[i]);
		
		int now = 0;
		int count = 0;
		
		while(now < n-1){
			now += dice[count];
			count++;
			now += field[now];			
		}
	
		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 608
s = input()


def check(w):
    if w[0] != 'A':
        return False
    n = len(w)
    count = 0
    for a in range(2, n-1):
        if w[a] == 'C':
            count += 1
    if count != 1:
        return False
    upper = 0
    for a in range(0, n):
        if w[a] >= 'A' and w[a] <= 'Z':
            upper += 1

    if upper != 2:
        return False
    return True


if check(s):
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3064
// https://atcoder.jp/contests/dp/tasks/dp_a
#include <bits/stdc++.h>
using namespace std;

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

int N;

int main() {
  cin >> N;

  vector<int> h(N);
  rep(i, 0, N) { cin >> h[i]; }

  vector<int> dp(N, 0);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);

  rep(i, 2, N) {
    int c1 = dp[i - 1] + abs(h[i - 1] - h[i]);
    int c2 = dp[i - 2] + abs(h[i - 2] - h[i]);
    dp[i] = min(c1, c2);
  }
  cout << dp[N - 1];
}

Measured memory_bytes: 1024
r=range;_,*s=open(0);m=9e9
h,w,k=map(int,_.split())
for i in r(1<<h-1):
 t=[j+1for j in r(h)if i>>j&1]+[h];l=len(t);v=-1;c=[0]*l
 for i in r(w):
  b=f=g=0;u=[]
  for j in r(l):d,b=sum(s[j][i]>"0"for j in r(b,t[j])),t[j];u+=d,;g|=d>k;c[j]+=d;f|=c[j]>k
  v+=f
  if f:c=u
 if not g:m=min(m,v+l)
print(m)

Measured memory_bytes: 50520
#include<stdio.h>
void swap(int *a, int *b)
{
	int c;
	if (*a>*b) c=*b,*b=*a,*a=c;
}
int main()
{
	int x,y;
	while (1) {
		scanf("%d%d",&x,&y);
		if (x==0&&y==0) break;
		swap(&x,&y);
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int H[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			H[i] = sc.nextInt();			
		}
		boolean good[] = new boolean[N];
		Arrays.fill(good, true);
		for(int i = 0 ; i < M ; ++i){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			if(H[a] <= H[b]){
				good[a] = false;
			}
			if(H[b] <= H[a]){
				good[b] = false;
			}
		}
		int ret = 0;
		for(boolean g : good){
			if(g){
				++ret;
			}
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 49544
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long ll;
int a[3001];
ll d[3001][3001];
ll mod = 998244353;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	int n, s; cin >> n >> s;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	d[0][0] = 0;// i까지왔는데의 합이 S인 경우의 수
	for (int i = 1; i <= n; i++) {
		d[i][a[i]] = i;
		for (int j = 0; j <= s; j++) {
			d[i][j] += d[i - 1][j];
			if (j - a[i] >= 0)
				d[i][j] += d[i - 1][j - a[i]];
			d[i][j] %= mod;
		}
		ans += d[i][s]; ans %= mod;
	}

	cout << ans << '\n';



}




Measured memory_bytes: 70656
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, K = il()
    # 累積和
    A = list(itertools.accumulate([0] + il()))
    B = list(itertools.accumulate(([0] + il())))

    # 尺取り法
    ret, m = 0, M
    for n in range(N + 1):
        if A[n] > K:
            break

        while B[m] > K - A[n]:
            m -= 1
        ret = max(ret, n + m)
    print(ret)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
ll inf = 1LL << 60;

int main() {
  ll A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> ss(A + 2, inf);
  ss[0] = -inf;
  vector<ll> ts(B + 2, inf);
  ts[0] = -inf;
  vector<ll> xs(Q);

  ll s;
  for (int i = 0; i < A; ++i) {
    cin >> s;
    ss[i + 1] = s;
  }

  ll t;
  for (int i = 0; i < B; ++i) {
    cin >> t;
    ts[i + 1] = t;
  }

  ll x;
  vector<ll> anss;
  for (int q = 0; q < Q; ++q) {
    cin >> x;

    auto d = upper_bound(ts.begin(), ts.end(), x) - ts.begin();
    auto b = upper_bound(ss.begin(), ss.end(), x) - ss.begin();
   
    vector<ll> tt = {ts[d - 1], ts[d]};
    vector<ll> sss = {ss[b - 1], ss[b]};

    ll ans = inf;
    for (size_t i = 0; i < sss.size(); ++i) {
      for (size_t y = 0; y < tt.size(); ++y) {
	ll d1 = abs(sss[i] - x) + abs(tt[y] - sss[i]);
	ll d2 = abs(tt[y] - x) + abs(sss[i] - tt[y]);
	ans = min({ans, d1, d2});
      }
    }
    anss.push_back(ans);
  }

  for (int i = 0; i < (int)anss.size(); ++i) {
    cout << anss[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    string s, t;
    cin >> s >> t;

    string u;

    for (int i = 0; i < n; i++)
    {
        u.push_back(s[i]);
        u.push_back(t[i]);
    }

    cout << u << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool flg=true;
	for(int i=0;i<s.size();i++)
		if(i%2==0)
		{
			if(s[i]!='h')flg=false;
		}
		else
			if(s[i]!='i')flg=false;
	if(s.size()%2==1)flg=false;
	cout << (flg ? "Yes":"No") << endl;




}

Measured memory_bytes: 256