akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN=1000+10;
int a[MAXN],n,m;
vector<int> ans;

int main()
{
	scanf("%d %d",&n,&m);
	int cnt=0;
	for(int i=1;i<=m;++i) scanf("%d",&a[i]),cnt+=a[i]&1;
	if(cnt>2){printf("Impossible\n");return 0;};
	for(int i=2;i<m;++i) 
		if(a[i]&1) a[1]&1?swap(a[i],a[m]):swap(a[i],a[1]);
	for(int i=1;i<=m;++i) printf("%d ",a[i]);
	if(m==1&&a[1]==1) ans.push_back(1);
	else if(m==1) ans.push_back(a[1]-1),ans.push_back(1);
	else 
	{
		if(a[1]!=1) ans.push_back(a[1]-1);
		for(int i=2;i<m;++i) ans.push_back(a[i]);
		ans.push_back(a[m]+1);
	};
	printf("\n%d\n",ans.size());
	for(int i=0;i<ans.size();++i) printf("%d ",ans[i]);
 	return 0;
}


Measured memory_bytes: 256
n = int(input())
H = list(map(int, input().split()))

C = [0]*(n)

for i in range(1, n):
  if i == 1:
    C[i] = abs(H[i]-H[i-1])
  else:
    C[i] = min(C[i-1]+abs(H[i]-H[i-1]), C[i-2]+abs(H[i]-H[i-2]))
  
print(C.pop())

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

using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int lenX = 0; int lenY = 0;
  lenX = x1 - x2;
  lenY = y1 - y2;
  cout << x2 + lenY << " ";
  cout << y2 - lenX << " ";
  cout << x1 + lenY << " ";
  cout << y1 - lenX << endl;
 
  return 0;
}

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


int main(void){

	int a,b,c;
	int count = 0;
	cin >> a >> b >> c;
	for(int i = a; i < (b+1); i++ ){
		if(c % i == 0) count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(2);
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int L=128;
set<pair<int,string>> st;
string let;

string ans;

int dp[1010][1010];
int cnt;
int query(string s) {
	printf("? %s\n",s.c_str());
	/*memset(dp,0x20,sizeof(dp));
	dp[0][0]=0;
	for (int i=0;i<=SZ(s);i++) for (int j=0;j<=SZ(ans);j++) {
		if (i==0||j==0) { dp[i][j]=i+j; continue; }
		dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1);
		dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(s[i-1]!=ans[j-1]));
	}
	int x=dp[SZ(s)][SZ(ans)];
	printf("%d %d\n",x,++cnt);
	return x;*/

	fflush(stdout);
	int x;
	scanf("%d",&x);
	return x;
}

void merge(string a,string &b) {
	int pos=0;
	rep(i,0,SZ(a)) {
		while (1) {
			string c=b;
			c.insert(c.begin()+pos,a[i]);
			if (query(c)==L-SZ(c)) {
				pos++;
				b=c;
				break;
			} else {
				pos++;
			}
		}
	}
}

int num[100];
int main() {
	rep(i,0,26) let.pb('A'+i);
	rep(i,0,26) let.pb('a'+i);
	rep(i,0,10) let.pb('0'+i);
	for (int i=0;i<100;i++) ans+=let[rnd(62)];
	sort(all(ans)); reverse(all(ans));
	int zz=0;
	rep(i,0,62) {
		string cc(L,let[i]);
		int x=query(cc);
		num[i]=x;
		zz+=x;
		//st.insert(mp(L-x,string(L-x,let[i])));
	}
	//printf("%d\n",L*62-zz);
	rep(i,0,62) st.insert(mp(L-num[i],string(L-num[i],let[i])));
	L=L*62-zz;
	while (SZ(st)>1) {
		string u=st.begin()->se; st.erase(st.begin());
		string v=st.begin()->se; st.erase(st.begin());
		merge(u,v);
		st.insert(mp(SZ(v),v));
	}
	printf("! %s\n",st.begin()->se.c_str());
}


Measured memory_bytes: 3812
from collections import Counter
s = input()
N = len(s)
K = int(input())
if s[0] != s[-1]:
    count = 1
    ans = 0
    now = s[0]
    for i in range(1,len(s)):
        if now == s[i]:
            count += 1
        else:
            now = s[i]
            ans += count//2
            count = 1
    if count != 1:
        ans += count//2
    print(ans*K)
elif len(Counter(s).values()) == 1:
    print(K*len(s)//2)
else:
    ans = 0
    fcount = 1
    bcount = 1
    now = s[0]
    start = N
    for i in range(1,N):
        if s[i] == now:
            fcount += 1
        else:
            start = i
            break
    now = s[-1]
    end= 0
    for i in range(N-2,-1,-1):
        if s[i] == now:
            bcount += 1
        else:
            end = i
            break   
    ans = fcount//2 + bcount//2 + ((fcount+bcount)//2)*(K-1)
    now = s[start]
    count = 1
    mcount = 0
    for i in range(start+1,end+1):
        if s[i] == now:
            count += 1
        else:
            mcount += count//2
            count = 1
            now = s[i]
    if count != 1:
        mcount += count//2
    print(ans + mcount*K)
                

Measured memory_bytes: 3316
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (ll)11;
ll CaseN=1;



ll tst(string s,ll n)
{
ll ans =0;	

	
return ans;
}



void solve()
{
	ll ans=0;
	ll n;
	cin>>n;
	ll a[n+2];
	for(ll i=1;i<=n;i++)
	{
	cin>>a[i];
	if(i&1)
	{
	if(a[i]&1)
	{
	ans++;	
	}	
	}	
	}
	
	
	cout<<ans<<endl;
	
	//cerr<<"Case #"<<CaseN<<": ";
    CaseN++;	

return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


Measured memory_bytes: 3636
#include<cstdio>
using ll = long long;
using ull = unsigned long long;
const static int MOD = 1000000007;

ll RepeatSquaring(ll N, ull P){
	if(P == 0 || N == 1) return 1;
	if(N == -1) return P & 1 ? -1 : 1;
	if(!(P & 1)){
		ll t = RepeatSquaring(N, P >> 1);
		return t*t %MOD;
	}
	return N*RepeatSquaring(N, P - 1) % MOD;
}
int main(){
    unsigned N;
    scanf("%u", &N);
    ull square = 0, tmp, sum = 0;
    for(unsigned i = 0; i < N;i++){
        scanf("%llu", &tmp);
        square = (tmp*tmp %MOD + square) %MOD;
        sum = (sum + tmp) %MOD;
    }
    printf("%llu\n", (sum*sum %MOD + MOD - square)%MOD *RepeatSquaring(2, MOD-2) %MOD);
	return 0;
}

Measured memory_bytes: 1696
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;
const int MAX=10010;

int r;

inline void input(int &x){
    int k=1; x=0; 
    char ch=0;
    while(ch<'0' || ch>'9') { ch=getchar(); if(ch=='-') k=-1; }
    while(ch>='0' && ch<='9') { x=x*10+ch-48; ch=getchar(); }
    x*=k;
}

int main(){
    input(r);
    if(r<1200) printf("ABC\n");
    else if(r<2800) printf("ARC\n");
    else printf("AGC\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0) cout << (b-a)/2 << endl;
    else cout << min(a-1, n-b)+1+(b-a-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h_list = list(map(int, input().split()))
ans = 0
for i in range(n):
    if abs(a - (t - h_list[i] * 0.006)) < abs(a - (t - h_list[ans] * 0.006)):
        ans = i
print(ans + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void input(int& rnMaxNum)
{
  cin >> rnMaxNum;
}

bool isDgt753(llong nRecNum)
{
  int nDgt3 = 0, nDgt5 = 0, nDgt7 = 0;

  while (nRecNum)
  {
    int n1stDgt = nRecNum % 10;

    if      (n1stDgt == 3) nDgt3++;
    else if (n1stDgt == 5) nDgt5++;
    else if (n1stDgt == 7) nDgt7++;

    nRecNum /= 10;
  }
  if (nDgt3 && nDgt5 && nDgt7)
    return true;
  else
    return false;
}

void dfs(int nMaxNum, llong nRecNum)
{
  static int stn753DgtCnt = 0;

  if (nRecNum > nMaxNum) return;
  if (isDgt753(nRecNum)) stn753DgtCnt++;

  dfs(nMaxNum, 10 * nRecNum + 3);
  dfs(nMaxNum, 10 * nRecNum + 5);
  dfs(nMaxNum, 10 * nRecNum + 7);

  if (!nRecNum) cout << stn753DgtCnt << endl;
}

int main()
{
  int nMaxNum;

  input(nMaxNum);
  dfs(nMaxNum, 0);

  return 0;
}

Measured memory_bytes: 3636
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    X = I()

    print(10 - X // 200)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10104
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      val n = readLine().split(" ").map(_.toInt)
      val (w,h,x,y,r) = (n(0),n(1),n(2),n(3),n(4))
      println(if(x-r < 0 || y - r < 0 || x + r > w || y + r > h) "No" else "Yes")

  }
}

Measured memory_bytes: 43796
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 200005
#define INF 1061109567
using namespace std;

int n, lmax, lmin, rmax, rmin;
long long ans1, ans2; 
struct node
{
	int x, y; 
} a[N]; 

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

bool cmp(node x, node y)
{
	return x.x < y.x; 
}

int main()
{
	n = read <int> ();
	lmax = rmax = -INF, lmin = rmin = INF; 
	for(int i = 1; i <= n; i++)
	{
		a[i].x = read <int> (), a[i].y = read <int> ();
		if(a[i].x > a[i].y) swap(a[i].x, a[i].y);
		lmax = max(lmax, a[i].y);
		lmin = min(lmin, a[i].y);
		rmax = max(rmax, a[i].x);
		rmin = min(rmin, a[i].x); 
	}
	sort(a + 1, a + n + 1, cmp); 
	ans1 = 1ll * (lmax - lmin) * (rmax - rmin);
	ans2 = INF, lmin = rmin, rmin = rmax = a[1].y;
	for(int i = 2; i <= n; i++)
	{
		rmax = max(rmax, a[i].y); 
		rmin = min(rmin, a[i].y);
		if(i != n) ans2 = min(ans2, 1ll * max(rmax, a[n].x) - min(rmin, a[i + 1].x)); 
	}
	ans2 = 1ll * ans2 * (lmax - lmin);
	printf("%lld\n", min(ans1, ans2)); 
	return 0; 
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stack>

using namespace std;

int main(){
	char buf1[100000],buf2[100000],pre;
	int n,p,count,tmp;
	stack<int> S;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;
		scanf("%s",buf1);

		for(int i=0;i<n;i++){
			p = count = 0;
			if(i%2 == 0){
				for(int k=0;buf1[k] != '\0';){
					if(k == 0){
						pre = buf1[k];
						count++;
						k++;
					}
					else{
						if(pre == buf1[k]){
							if(buf1[k+1] != '\0'){
								count++;
							}else{
								count++;
								if(count >= 10){
									while(count != 0){
										S.push(count%10);
										count /= 10;
									}
									while(!S.empty()){
										tmp = S.top();
										S.pop();
										buf2[p++] = '0' + tmp;
									}
									buf2[p++] = pre;
									buf2[p++] = '\0';

								}else{
									buf2[p++] = '0' + count;
									buf2[p++] = pre;
									buf2[p++] = '\0';
								}
							}
							k++;
						}
						else{
							if(count >= 10){
								while(count != 0){
									S.push(count%10);
									count /= 10;
								}
								while(!S.empty()){
									tmp = S.top();
									S.pop();
									buf2[p++] = '0' + tmp;
								}
								buf2[p++] = pre;
							}else{
								buf2[p++] = '0' + count;
								buf2[p++] = pre;
							}
							pre = buf1[k];
							count = 0;
						}
					}
				}
			}else{
				for(int k=0;buf2[k] != '\0';){
					if(k == 0){
						pre = buf2[k];
						count++;
						k++;
					}
					else{
						if(pre == buf2[k]){
							if(buf2[k+1] != '\0'){
								count++;
							}else{
								count++;
								if(count >= 10){
									while(count != 0){
										S.push(count%10);
										count /= 10;
									}
									while(!S.empty()){
										tmp = S.top();
										S.pop();
										buf1[p++] = '0' + tmp;
									}
									buf1[p++] = pre;
									buf1[p++] = '\0';

								}else{
									buf1[p++] = '0' + count;
									buf1[p++] = pre;
									buf1[p++] = '\0';
								}
							}
							k++;
						}
						else{
							if(count >= 10){
								while(count != 0){
									S.push(count%10);
									count /= 10;
								}
								while(!S.empty()){
									tmp = S.top();
									S.pop();
									buf1[p++] = '0' + tmp;
								}
								buf1[p++] = pre;
							}else{
								buf1[p++] = '0' + count;
								buf1[p++] = pre;
							}
							pre = buf2[k];
							count = 0;
						}
					}
				}
			}
		}

		if(n%2 == 1)printf("%s\n",buf2);
		else{
			printf("%s\n",buf1);
		}
	}

    return 0;
}

Measured memory_bytes: 2548
def main():
    moji = list(input())
    hint = list(input())


    for i in range(len(moji) - len(hint) + 1)[::-1]:
        flg = 1
        for j in range(len(hint)):
            if moji[i + j] == '?':
                continue
            if hint[j] != moji[i + j]:
                flg = 0
                break
        if flg:
            for j in range(len(hint)):
                moji[i + j] = hint[j]
            for j in range(len(moji)):
                if moji[j] == '?':
                    moji[j] = 'a'
            print(''.join(moji))
            break
    else:
        print('UNRESTORABLE')



if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
N = int(input())
cnt = 0

if (N >= 105):
    
    for num in range(105, N + 1, 2):

        divisor = []
        
        for i in range(1, num + 1):
            if (num % i == 0):
                divisor.append(i)
        
        if (len(divisor) == 8):
            cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, ww;
  cin >> n >> ww;
  vll w(n), v(n);
  for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];
  vll dp(100001, 0);
  vector<vll> check(1, vll(n, 0));
  for (ll i = 1; i <= ww; i++) {
    dp[i] = dp[i - 1];
    ll memo = -1;
    for (ll j = 0; j < n; j++) {
      if (i < w[j]) continue;
      if (check[i - w[j]][j] == 1) continue;
      if (dp[i] < dp[i - w[j]] + v[j]) {
        dp[i] = dp[i - w[j]] + v[j];
        memo = j;
      }
    }
    if (memo != -1) {
      vll x = check[i - w[memo]];
      x[memo] = 1;
      check.push_back(x);
    }
    else check.push_back(check[i - 1]);
  }
  cout << dp[ww] << endl;
}

Measured memory_bytes: 83120
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cmath>
#include <climits>
#include <queue>

using namespace std;


int main() {
    int n; cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> h(n);
    int maxh = 0;
    for(int i = 0; i < n; ++i){
        cin >> x[i];
        cin >> y[i];
        cin >> h[i];
        maxh = max(maxh, h[i]);
    }

    for(int k = maxh + 210; k >= 0; --k){
        for(int i = 0; i <= 100; ++i){
            for(int j = 0; j <= 100; ++j){
                bool flag = true;
                for(int l = 0; l < n ; ++l){
                    if(max(k - abs(i - x[l]) - abs(j - y[l]), 0) != h[l]){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll a[MAX];


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


  ll k, q;
  cin >> n >> k >> q;
  rep(i, q) {
    cin >> tmp;
    a[tmp]++;
  }
  FOR(i, 1, n + 1) {
    if (k - q + a[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }




  return 0;
}


Measured memory_bytes: 1408
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
int c[501], s[501], f[500];

void init()
{
}

void solve()
{
    REP(i, N){
        int ans = 0;
        FOR(j, i, N-1){
            if(ans < s[j]) ans = s[j];
            else if(ans % f[j] != 0) ans += (f[j] - (ans % f[j]));
            ans += c[j];
        }
        cout << ans << endl;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N-1) cin >> c[i] >> s[i] >> f[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
def C(n, k):
	ans = 1
	for i in range(k):
		ans = ans * (n - i) / (i + 1)
	return int(ans)
N = int(input())
A = list(map(int, input().split()))
s = 0
d = {0: 1}
for i in A:
	s = s + i
	d[s] = d.get(s, 0) + 1
ans = 0
for i in d:
	if d[i] > 1:
		ans  = ans + C(d[i], 2)
print(ans)

Measured memory_bytes: 39700
#include <iostream>

using namespace std;
string s , t;
int main(){
    cin >> s >> t;
    int ans = t.size();
    for (int i = 0; i < s.size() - t.size() + 1; i++){
        int cnt = 0;
        for (int j = 0; j < t.size(); j++)
            if (s[i + j] != t[j]) cnt++;
        ans = min(ans,cnt);
    }
    cout << ans;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;

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

  int n, k;
  cin >> n >> k;

  vector<int> dp(k + 1, 0);
  dp[0] = 1;

  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    for (int j = 1; j <= k; ++j) dp[j] = (dp[j] + dp[j-1]) % M;
    vector<int> tmp(k + 1, 0);
    for (int j = 0; j <= k; ++j) {
      int l = j - x;;
      tmp[j]  = dp[j];
      if (l > 0) tmp[j] = (tmp[j] - dp[l-1] + M) % M;
    }
    swap(tmp, dp);
  }
  cout << dp[k] << '\n';
}


Measured memory_bytes: 4012
W, H, N = gets.split.map(&:to_i)
dp = Array.new(H) { ' ' * (W) }
points = readlines.map { |l| l.split.map(&:to_i) }
points.each do |x, y, a|
  case a
  when 1
    dp.length.times do |i|
      (0..x-1).each do |dx|
        dp[i][dx] = '#'
      end
    end
  when 2
    dp.length.times do |i|
      (x..dp.length).each do |dx|
        dp[i][dx] = '#'
      end
    end
  when 3
    (0..y-1).each do |dy|
      dp[dy] = '#' * (W + 1)
    end
  when 4
    (y..dp.length).each do |dy|
      dp[dy] = '#' * (W + 1)
    end
  end
end

result = 0
dp.each do |dy|
  result += dy.chars.count { |s| s == ' ' }
end
p result

Measured memory_bytes: 2172
import java.util.Scanner;

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

    int a = scanner.nextInt();
    int b = scanner.nextInt();

    String result = a * b % 2 == 0 ? "Even" : "Odd";

    System.out.println(result);
  }
}

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

int main() {
  int N,c=1;
  cin>>N;
  vector<int> d(N);
  
  for(int i=0;i<N;i++){
    cin>>d.at(i);
  }
  
  sort(d.begin(),d.end());
  for(int i=0;i<N-1;i++){
    if(d.at(i)!=d.at(i+1))c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxN=1e5+12;
int n,a[maxN],ans;
int32_t main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    ans+=a[i]%2;
  }
  if(ans%2==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

using namespace std;

int main() {
    string s;   int n;  cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < n-2; i++) {
        if (s.substr(i, 3) == "ABC")
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a, b; cin >> a >> b;
  if(a * b == 2) cout << 3 << endl;
  else if(a * b == 3) cout << 2 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;

#define MAXN 100000 
#define level 18 
  
vector <int> tree[MAXN]; 
int depth[MAXN]; 
int parent[MAXN][level]; 
  
// pre-compute the depth for each node and their 
// first parent(2^0th parent) 
// time complexity : O(n) 
void dfs(int cur, int prev) 
{ 
    depth[cur] = depth[prev] + 1; 
    parent[cur][0] = prev; 
    for (int i=0; i<tree[cur].size(); i++) 
    { 
        if (tree[cur][i] != prev) 
            dfs(tree[cur][i], cur); 
    } 
} 
  
// Dynamic Programming Sparse Matrix Approach 
// populating 2^i parent for each node 
// Time complexity : O(nlogn) 
void precomputeSparseMatrix(int n) 
{ 
    for (int i=1; i<level; i++) 
    { 
        for (int node = 1; node <= n; node++) 
        { 
            if (parent[node][i-1] != -1) 
                parent[node][i] = 
                    parent[parent[node][i-1]][i-1]; 
        } 
    } 
} 
  
// Returning the LCA of u and v 
// Time complexity : O(log n) 
int lca(int u, int v) 
{ 
    if (depth[v] < depth[u]) 
        swap(u, v); 
  
    int diff = depth[v] - depth[u]; 
  
    // Step 1 of the pseudocode 
    for (int i=0; i<level; i++) 
        if ((diff>>i)&1) 
            v = parent[v][i]; 
  
    // now depth[u] == depth[v] 
    if (u == v) 
        return u; 
  
    // Step 2 of the pseudocode 
    for (int i=level-1; i>=0; i--) 
        if (parent[u][i] != parent[v][i]) 
        { 
            u = parent[u][i]; 
            v = parent[v][i]; 
        } 
  
    return parent[u][0]; 
}


int main()
{
    
    // #ifndef ONLINE_JUDGE
    //     freopen ("data.in","r",stdin);
    //     freopen ("E.out","w",stdout);
    // #endif
    cin.sync_with_stdio( false );

    int tests=1;
    // cin>>tests;
    while(tests--)
    {
    	ll a,b,n;
    	cin>>a>>b>>n;
    	if(n>=b-1)
    	{
    		cout<<(a*(b-1))/b;
    	}
    	else
    	{
    		cout<<(a*n)/b;
    	}
   	}
    	return 0;
    
}

Measured memory_bytes: 5940
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, X, T; cin >> N >> X >> T;
  int ans = ((N+X-1)/X)*T;
  cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pi;

const int MOD = (int)(1e+9 + 7);
int N, M;
ll ans;
vector<vvl> dp;
vector<vector<pi> > term;

void solve(void) {
	ans = 0LL;
	dp[0][0][0] = 1;
	for (int r = 0; r <= N; ++r) {
		for (int g = 0; g <= N; ++g) {
			if (g != 0 && g == r) continue;
			for (int b = 0; b <= N; ++b) {
				if (b != 0 && (b == r || b == g)) continue;
				int mx = max(r, max(g, b));
				for (int p = 0; p < (int)term[mx].size(); ++p) {
					int cnt = 0;
					if (r >= term[mx][p].first)	++cnt;
					if (g >= term[mx][p].first)	++cnt;
					if (b >= term[mx][p].first)	++cnt;
					if (cnt != term[mx][p].second) {
						dp[r][g][b] = 0;
						break;
					}
				}
				dp[r][g][b] %= MOD;
				if (mx == N) {
					ans += dp[r][g][b];
					ans %= MOD;
				}
				else {
					dp[mx + 1][g][b] += dp[r][g][b];
					dp[r][mx + 1][b] += dp[r][g][b];
					dp[r][g][mx + 1] += dp[r][g][b];
				}
			}
		}
	}
}

int main(void) {
	cin >> N >> M;
	vl v;
	v.resize(N + 1, 0LL);
	vvl vv;
	vv.resize(N + 1, v);
	dp.resize(N + 1, vv);
	term.resize(N + 1);
	for (int i = 0; i < M; ++i) {
		int l, r, x;
		cin >> l >> r >> x;
		term[r].push_back(make_pair(l, x));
	}
	solve();

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


Measured memory_bytes: 216832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int a,b,x;
    cin >> a >> b >> x;
    if(x <= a+b && x >= a){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
const ll MOD = 1e9 + 7;


// 多次元vector生成，初期化
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

//pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) { return s << "(" << p.first << ", " << p.second << ")"; }

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

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream & s, const vector< vector<T> > & vv) {int len = vv.size();for (int i = 0; i < len; ++i) {s << vv[i] << endl;}return s;}

ll dp[1 << 14];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<int> a(M), b(M), c(M, 0);


	for (int i = 0; i < M; i++)
	{
		cin >> a[i] >> b[i];

		int cnt = 0;
		for (int j = 0; j < b[i]; j++)
		{
			int t;
			cin >> t;
			cnt += (1 << (t - 1));
		}
		c[i] = cnt;
	}
	for (int i = 0; i < 1 << 14 - 1; i++)
	{
		dp[i] = LINF;
	}

	dp[0] = 0;

	for (int i = 0; i < (1 << N); i++)
	{
		for (int j = 0; j < M; j++)
		{
			dp[(i | c[j])] = min(dp[(i | c[j])], dp[i] + a[j]);
		}
	}

	if (dp[(1 << N) - 1] == LINF) {
		cout << "-1" << endl;
	}
	else
	{
		cout << dp[(1 << N) - 1] << endl;
	}
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
    vector<ll> v_{};
    explicit C1(vector<ll> v) : v_(move(v)){}
    explicit C1(ll N, vector<ll> r, vector<tuple<ll, ll, ll>> v) {}
    ll resolve() {
        return 0;
    }
};

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define INF (1e12)
#define MAX 500000



int main(){
    int n, m;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    cin >> m;
    vector<string> t(m);
    rep(i,m) cin >> t[i];
    int ans = 0;
    rep(i,n){
        int tmp = 0;
        rep(j,n)if(s[i] == s[j]) tmp++;
        rep(j,m)if(s[i] == t[j]) tmp--;
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
  long long X;
  cin >> X;
  
  long long N=100;
  int count=0;
  
  while(1){
    N += N/100;
    count++;
    
    if(N>=X){
      break;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x,tong=0,n,X,M=INT_MAX;
    cin>>n>>X;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        M=min(M,x);
        tong+=x;
    }
    cout<<n+(X-tong)/M;
}


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

int main()
{
    int n;
    long long sum = 0;
    cin >> n;
    int a[n];

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

    if(sum%2) cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, a, h = 0, ans = 0;
  cin >> n;

  rep(i, n) {
    cin >> a;
    h = max(h, a);
    ans += max(h - a, 0LL);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<float, float>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<PII> p(n);
    for(auto &x : p){
        cin >> x.F >> x.S;
    }
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        v[i] = i;
    }
    double ans = 0;
    double j = 0;
    do{
        double sum = 0;
        for(int i = 1; i < n; i++){
            function<float(PII, PII)> dist = [&](PII p1, PII p2){
                return sqrtf((p1.F - p2.F) * (p1.F - p2.F) + (p1.S - p2.S) * (p1.S - p2.S));
            };
            sum += dist(p[v[i - 1]], p[v[i]]);
        }
        ans += sum;
        j++;
    }while(next_permutation(ALL(v)));
    ans /= j;
    cout << fixed << setprecision(10) << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n),sum(n);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
        if(i)
          sum[i]=sum[i-1]+v[i];
        else
          sum[i]=v[i];
    }
    map<ll,ll> m;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(sum[i]==0)
          ans+=m[sum[i]]+1;
        else if(m[sum[i]])
          ans+=m[sum[i]];
        m[sum[i]]++;
    }
    cout<<ans;

   return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>
using namespace std;
const int mod = 1e9 + 7;
vector<vector<int>> dp;

int path(vector<vector<int>>& arr, int row, int col, int i, int j) {
	if (i >= row || j >= col) {
		return 0;
	}
	if (arr[i][j] == 1) {
		return 0;
	}
	if (i == row - 1 && j == col - 1) {
		return 1;
	}
	int& ans = dp[i][j];
	if (dp[i][j] != -1) {
		return ans;
	}
	int rightMove = path(arr, row, col, i, j + 1)%mod;
	int downMove = path(arr, row, col, i + 1, j)%mod;
	ans = (rightMove + downMove)%mod;
	return ans;
}

int main() {
	int row, col;
	cin >> row >> col;
	vector<vector<int>> arr(row, vector<int>(col, 0));
	for (int i = 0; i < row; i++) {
		for (int j = 0; j < col; j++) {
			char ch; 
			cin >> ch;
			if (ch == '.') {
				arr[i][j] = 0;
			}
			else {
				arr[i][j] = 1;
			}
		}
	}
	if (arr[row - 1][col - 1] == 1) {
		cout << "0" << endl;
		return 0;
	}
	dp.resize(row, vector<int>(col, -1));
	//vis.resize(row, vector<int>(col, 0));
	cout << path(arr, row, col, 0, 0);
	return 0;
}

Measured memory_bytes: 8320
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vl a(n);
    map<int, vi> idxl, idxr;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i != n - 1)
            idxl[a[i]].push_back(i);
        if (i != 0)
            idxr[a[i]].push_back(i);
    }
    ll mid = 0;
    ll ret = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i - 1] > a[i])
            mid++;
        ll diff = a[i] - a[i - 1];
        if (diff < 0)
            diff += m;
        ret += min(a[i], diff);
    }
    ll temp = ret;
    for (int i = 2; i <= m; ++i) {
        temp -= mid;
        if (idxl.count(i - 1) != 0) {
            mid += idxl[i - 1].size();
        }
        if (idxr.count(i - 1) != 0) {
            for (auto &p : idxr[i - 1]) {
                mid--;
                temp++;
                ll diff = a[p] - a[p - 1];
                if (diff < 0)
                    diff += m;
                temp += diff - 1;
            }
        }
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 17408
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vi a(n);
	rep(i, n) cin >> a[i];

	for (int r = k; r < n; ++r) {
		int l = r - k;

		if (a[l] < a[r]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


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


int main() {
  int X; cin>>X;
  
  if(X>=1800)cout<<"1\n";
  else if(X>=1600)cout<<"2\n";
  else if(X>=1400)cout<<"3\n";
  else if(X>=1200)cout<<"4\n";
  else if(X>=1000)cout<<"5\n";
  else if(X>=800)cout<<"6\n";
  else if(X>=600)cout<<"7\n";
  else cout<<"8\n";
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    int c=a%n;
    if(c==0)
    {
        cout<<"OK"<<endl;
    }
    else
    {
        c=n-c;
        if(c+a<=b)
        cout<<"OK"<<endl;
        else
        cout<<"NG"<<endl;
    }
}


Measured memory_bytes: 3652
import sys
n,t=map(int,input().split())
T=list(map(int,input().split()))
ans=0
starttime=0
endtime=0
for i in T:
  if endtime>=i:
    endtime=endtime-(endtime-i)+t
  else:
    ans+=endtime-starttime
    starttime=i
    endtime=i+t
ans+=endtime-starttime
print(ans)

Measured memory_bytes: 25200
def solve():
    H, W = list(map(int, input().split(" ")))
    d, A = [], []
    for _ in range(10):
        d.append(list(map(int, input().split(" "))))
    for _ in range(H):
        A += list(map(int, input().split(" ")))

    V, E = 10, 35
    for k in range(V):
        for i in range(V):
            for j in range(V):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    sum = 0
    for a in A:
        if a == -1:
            pass
        else:
            sum += d[a][1]

    print(sum)
 

solve()

Measured memory_bytes: 3572
N,*A = `dd`.split.map &:to_i
sa = A.sort

x = sa.pop
y = sa.shift
ops = sa.map{ |z|
  if z >= 0
    y0 = y
    y -= z
    [y0,z] * " "
  else
    x0 = x
    x -= z
    [x0,z] * " "
  end
}
ops << [x,y] * " "
p x-y
puts ops


Measured memory_bytes: 34668
#include<stdio.h>
#include<string.h>

int a,b,i;
char s[120];

int main(){
	scanf("%s",s);
	while(strcmp(s,"0")!=0){
		a=b=0;
		for(i=1;i<strlen(s);i++){
			if(s[i]=='A')a++;
			else b++;
		}
		if(a>b)a++;
		else b++;
		printf("%d %d\n",a,b);
		scanf("%s",s);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int n,ans=0,minn=inf;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);

	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		if(x<=minn) ++ans;
		minn=min(minn,x);
	}

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

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    int i=1;
    int b=0;
    for(;i<10;i++){
        if(a%i==0 && a/i<10){
            cout<<"Yes"<<endl;
            break;
        }else{
            b++;
        }
    }if(b==9){
        cout<<"No"<<endl;
    }
    
}


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

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

#ifndef ATAKYN
#define endl '\n'
#endif

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

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

    vector<string> a(h);

    for (int i = 0; i < h; i++)
        cin >> a[i];

    ll MOD = 1000000007;

    // number of paths to dp[i][j]
    vector<vector<ll>> dp(h + 1, vector<ll>(w + 1));
    dp[1][1] = 1;
    
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (a[i - 1][j - 1] == '.') {
                dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
                dp[i][j] %= MOD;
            }
        }
    }

    cout << dp[h][w] << endl;
}



Measured memory_bytes: 9216