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

int num[1000001];

int main() {
	int a, b, n;
	while( cin >> a ) {
		cin >> b >> n;
		
		a = a%b;
		for(int i = 0; i <= n; i++ ) {
			num[i] = a/b;
			a -= num[i] * b;
			a *= 10;
		}
		
		int ans = 0;
		//cout << ".";
		for(int i = 1; i <= n; i++ ) {
			//cout << num[i];
			ans += num[i];
		}
		//cout << endl;
		cout << ans << endl;
	}
	return 0;
}

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

char str[100];

int main() {
  scanf("%s", str);
  int len = strlen(str);
  for (int i = 0; i < len; i++) {
    if (str[i] == '9') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}

Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    int x = 0;
    REP(i,N) {
        if(S.at(i) == 'I') x++;
        else x--;
        chmax(ans,x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
s = []
c_sum = sum(c)
for i in range(D):
    tmp = list(map(int, input().split()))
    s.append(tmp)
t = []
for i in range(D):
    tmp = int(input())
    t.append(tmp-1)
cnt = [-1 for j in range(26)]
now = 0
for i in range(D):
    cnt[t[i]] = i
    now += s[i][t[i]]
    tmp = 0
    for j in range(26):
        if j != t[i]:
            if cnt[t[i]] == -1:
                tmp += c[j] * (i + 1)
            else:
                tmp += c[j] * (i - cnt[j])
    now -= tmp
    print(now)

Measured memory_bytes: 9360
#include <cstdio>
#include <numeric>
 
int const N = 1000001;
 
int spf[N], u[N], s[17], d, i, j, k;
char const* r = "pairwise";
 
int main() {
    while (++i < N) spf[i] = i;
    for (i = 2; i * i < N; i++)
        for (j = i * i; j < N; j += i)
            if (spf[j] == j) spf[j] = i;
    for (scanf("%*d"); ~scanf("%d", &j);) {
        d = std::gcd(d, j);
        for (; j > 1; j /= i)
            if (u[s[k++] = i = spf[j]]) r = "setwise";
        while(k) u[s[--k]] = 1;
    }
    printf("%s coprime\n", d > 1 ? "not" : r);
    return 0;
}


Measured memory_bytes: 9496
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
m = 0
b = []
cnt = [[] for _ in range(n+1)]
for i in range(1, n+1):
    j = i
    c = 1
    while j*c <= n:
        cnt[j*c].append(i)
        c += 1

tmp = [0]*(n+1)
for i in range(n)[::-1]:
    if tmp[i+1] % 2 != a[i]:
        b.append(i+1)
        m += 1
        for j in cnt[i+1]:
            tmp[j] += 1

print(m)
print(*b[::-1])


Measured memory_bytes: 157148
def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

n = int(input())
a = list(map(int, input().split()))

left = [0] * (n + 1)
for i in range(1, n):
    left[i] = gcd(left[i - 1], a[i - 1])

right = [0] * (n + 1)
for i in range(1, n):
    right[n - i] = gcd(right[n - i + 1], a[n - i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i + 1]))
print(ans)


Measured memory_bytes: 63856
#include<stdio.h>

int main(){
  int i ,j ; 
  int n= 0 ;
  int x = 0 ;
  int wantSum = 0; 
  int count = 0 ; 
  int lestChiled;
  int okChildFlag;
  scanf("%d",&n);
  lestChiled = n ;
  scanf("%d",&x);
  int a[n] ; 
  for( i = 0; i < n ; i++)
  {
    scanf("%d",&a[i]);
    wantSum += a[i];
  }
  int min = 1000000000;
  int max = 0 ;
  for (i = 0 ; i < n ; i++) {
    if(a[i] > max) max = a[i];
    if(a[i] < min)
    {
      okChildFlag = i;
      min = a[i];
    }
    }

  while(x >= min && lestChiled > 1){
    x       -= min; 
    min =           1000000000;
    a[okChildFlag]= 1000000000;
    count++;
    lestChiled--;
    for (i = 0 ; i<n ; i++){
      if(a[i] < min) {
        min = a[i];
        okChildFlag = i;
      }
    }
  }
 if (x == max) count++;
  printf("%d\n",count);
  return 0 ;
}

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

bool is_palindromic(int x) {
  string s = to_string(x);

  for (int i = 0; i < s.size() / 2; ++i) {
    if (s[i] != s[s.size() - 1 - i]) return false;
  }

  return true;
}

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

  int a, b;
  cin >> a >> b;

  int res = 0;
  for (int x = a; x <= b; ++x) {
    if (is_palindromic(x)) res++;
  }

  cout << res << "\n";
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll X,N; cin>>X>>N;
  map<ll,bool> M;
  for(ll i=0; i<N; i++){
    ll P; cin>>P;
    M[P]=true;
  }
  for(ll i=0; i<1000; i++){
    ll n=X-i;
    ll m=X+i;
    if(M[n]==false){
      cout<<n<<endl;
      return 0;
    }
    if(M[m]==false){
      cout<<m<<endl;
      return 0;
    }
  }
}

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

using namespace std;

vector<int> v;
int n,t;
int main() {

    cin >> n;
    cin >> t;
    v.push_back(t);
    bool k = false;
    for (int i = 1; i < n; i++) {
        cin >> t;
        if (k == false) {
            v.push_back(t);
            k = true;
        }
        else {
            v.insert(v.begin(), t);
            k = false;
        }
    }
    if (k == false) {
        for(int i = 0; i < n; i++)
            cout << v[i] << " ";
    } else {
        for(int i = n-1; i >= 0; i--)
            cout << v[i] << " ";

    }
    cout << endl;

   return 0;

}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

void swap(ll a, ll b)
{
  ll tmp = a;
  a = b;
  b = tmp;
}

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

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

int main(int argc, char const *argv[])
{
  ll t;
  cin >> t;
  REP(i, t)
  {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b > d || a < b)
    {
      cout << "No" << endl;
      continue;
    }
    ll cur = a;
    ll vgcd = gcd(max(b, d), min(b, d));

    if (a <= c)
    {
      if (b == d)
      {
        cout << "Yes" << endl;
        continue;
      }
      a = a + (d - b) * ((c - a) / (d - b));
    }
    if (a - ((a - (c + 1)) / vgcd) * vgcd - b >= 0)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        int j = x - i;
        if (2 * i + 4 * j == y) {
            cout << "Yes" << newl;
            return 0;
        }
    }
    cout << "No" << newl;
}

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

int main() {
    double a, b, x, d, radian;
    cin >> a >> b >> x;
    double c = x / a / a;
    if (a*a*b/2 >= x) {
        radian = atan(a*b*b/(2*x));
    }
    else radian = atan(2*(b-c)/a);
    double degree = radian * 180.0 / PI;
    printf("%.10lf\n", degree);
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<int>adj[200100];
bool visit[200100];
bool ok[200100];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i = 0 ; i<m ; i++)
    {
        int u,v;
        scanf("%d%d" , &u , &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
        if(u==n) ok[v] = 1;
        if(v==n) ok[u] = 1;
    }

    for(int i = 0 ; i<adj[1].size() ; i++)
    {
        int to = adj[1][i];
        if(ok[to]) visit[n] = 1;
    }
    if(visit[n]) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 12144
using System;

namespace AtCoderTest
{
    class Program
    {
        static void Main()
        {
            string S = Console.ReadLine().Trim();
            string ans = string.Empty;

            int i = 0;
            foreach (var ss in S) {
                ans += ss;
                if (i++ == 2) break;
            }
            Console.WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 25636
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
char s[1000010];
int i,x,d[1000010][2]={0,1};
int main(){
  scanf("%s",s);
  for(i=0;s[i];i++){
    x=s[i]-'0';
    d[i+1][0]=MIN(d[i][0]+x  ,d[i][1]+10-x);
    d[i+1][1]=MIN(d[i][0]+x+1,d[i][1]+9 -x);
  }
  printf("%d\n",d[i][0]);
  return 0;
}


Measured memory_bytes: 8960
#include <stdio.h>
#include <math.h>
int main(void){
    int n, d;
    int ans=0;
    scanf("%d %d", &n, &d);
    for(int i=0; i<n; i++){
        long int x, y;
        scanf("%ld %ld", &x, &y);
        if(sqrt(x*x+y*y)<=d)ans++;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  set<ll> st;
  rep(i, s.size()) st.insert(s[i]);
  cout << (st.size() == s.size() ? "yes" : "no") << endl;
}

Measured memory_bytes: 3576
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a + b - 1) / b)
#define tomax(a, b) (a = max(a, b))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n, x, t;
    cin >> n >> x >> t;
    cout << iceil(n, x) * t << "\n";

    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int dp[3001][3001];
int main(void)
{
	int i,j,n,t,s,a[3001],b[3001],max;
	scanf("%d%d%d",&n,&t,&s);
	for(i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]);
	for(i=0;i<=n;i++){
		for(j=0;j<=t;j++) dp[i][j]=-1;
	}
	dp[0][0]=0;
	for(i=0;i<n;i++){
		for(j=0;j<=t;j++){	
			if(dp[i][j]!=-1){
				if(dp[i][j]>dp[i+1][j]) dp[i+1][j]=dp[i][j];
				if(s>=j+b[i]||s<=j){
					if(j+b[i]<=t&&dp[i][j]+a[i]>dp[i+1][j+b[i]]) dp[i+1][j+b[i]]=dp[i][j]+a[i];
				}
				else if(s+b[i]<=t&&dp[i][j]+a[i]>dp[i+1][s+b[i]]) dp[i+1][s+b[i]]=dp[i][j]+a[i];
			}
		}
	}
/*	for(i=0;i<=n;i++){
		for(j=0;j<=t;j++) printf("%d ",dp[i][j]);
			printf("\n");
	}*/
	max=0;
	for(i=0;i<=t;i++){
		if(max<dp[n][i]) max=dp[n][i];
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 37884
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



// queueを用いた場合の実装(経路復元無し)
const int MAX_E = 100100;
const int MAX_V = 100100;
struct edge{ll to, cost;};
int V;
ll d[MAX_V];

void dijkstra(int s ,vector<vector<edge>> &G){
  // greater<PII>を指定することでfirstが小さい順に取り出せるようにする
  priority_queue<PLL, vector<PLL>, greater<PLL>> que;
  fill(d,d+V,LINF); d[s]=0LL; que.push(PLL(0LL,s));
  while(!que.empty()){
    PLL p = que.top(); que.pop();
    ll v = p.second;
    if(d[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e = G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to] = d[v]+e.cost;
        que.push(PLL(d[e.to], e.to));
      }
    }
  }
}


signed main(){
	int m,s,t; cin>>V>>m>>s>>t; s--; t--;
	ll u[m],v[m],a[m],b[m];
	int n=V;
	rep(i,m){
		cin>>u[i]>>v[i]>>a[i]>>b[i]; u[i]--; v[i]--;
	}
	vector<vector<edge>> G1(V), G2(V);
	rep(i,m){
		edge e1; e1.to=v[i]; e1.cost=a[i];
		edge e2; e2.to=u[i]; e2.cost=a[i];
		G1[u[i]].PB(e1); G1[v[i]].PB(e2);
	}
	dijkstra(s,G1);
	ll da[n]; rep(i,n) da[i]=d[i];
	rep(i,m){
		edge e1; e1.to=v[i]; e1.cost=b[i];
		edge e2; e2.to=u[i]; e2.cost=b[i];
		G2[u[i]].PB(e1); G2[v[i]].PB(e2);
	}
	dijkstra(t,G2);
	ll db[n]; rep(i,n) db[i]=d[i];

	ll cost[n]; rep(i,n) cost[i]=da[i]+db[i];
	ll min_cost=LINF;
	ll ans[n];
	REP(i,n){
		chmin(min_cost,cost[i]);
		ans[i]=(ll)1e15-min_cost;
	}
	rep(i,n) cout<<ans[i]<<endl;
	return 0;
}


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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, N;
    cin >> A >> B >> N;
    int ans = 0;
    int cnt = 0;
    if (B - 1 <= N) {
        int i = B - 1;
        ans = max(ans, A * i / B - A * (i/B));
        cout << ans << endl;
        return 0;
    }
    if(B - 1 > N) {
        int i = N;
        ans = max(ans, A * i / B - A * (i/B));
        cout << ans << endl;
        return 0;
    }
    return 0;
}
//10000 2000000 150000

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

const int H_MAX = 6;
const int W_MAX = 6;

int h, w, k;
char c[H_MAX][W_MAX];

int main(){
    cin >> h >> w >> k;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++)cin >> c[i][j];
    }

    int ans = 0;
    for(int S = 0; S != 1 << (h+w); S++){
        int num = 0;
        for(int i = 0; i < h; i++){
            if (S & 1 << i)continue;
            for(int j = 0; j < w; j++){
                if (S & 1 << (h+j))continue;
                if (c[i][j] == '#')num++;
            }
        }
        if (num == k)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
n0 = n
money = [1]
pow6 = 6
while pow6 <= n:
    money.append(pow6)
    pow6 *= 6
# pow9 = 9
# while pow9 <= n:
#     p.append(pow9)
#     pow9 *= 9
money.sort(reverse = True)

def cnt(x):
    res = 0
    while x > 0:
        res += x%9
        x = x // 9
    return res
anst = 1e100
for i in range(n0//9+1):
    ans = cnt(i)
    n = n0 - i*9
    for m in money:
        if m <= n:
            ans += n//m
            n %= m
    anst = min(anst,ans)
print(anst)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<numeric>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;++i) cin >> v[i];
  int m;
  cin >> m;
  int px[m][2];
  for(int i=0;i<m;++i){
    for(int j=0;j<2;++j) cin >> px[i][j];
  }
  for(int i=0;i<m;++i){
    auto temp = v;
    temp[px[i][0]-1] = px[i][1];
    cout << accumulate(temp.begin(),temp.end(),0) << endl;
  }


  return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  int sum = 0;
  for (int i = 0 ; i < M ; i++) {
     int a;
     cin >> a;
     sum += a;
  }
  if(N < sum) cout << -1 << endl;
  else cout << N - sum << endl;
}


Measured memory_bytes: 3644
import sys
S = input()
T = input()
ans = []
o = []
def check(S, T):
    for i in range(len(S)):
        if (T[i] == S[i]) or (S[i] == "?"):
            pass
        else:
            return False
    else:
        return True
    
hint_len = len(T)
UnCheck = True
for i in range(len(S)-(hint_len+1) , -2 , -1):
    if check(S[i+1:i+hint_len+1], T):
        Z = list(S)
        Z[i+1:i+hint_len+1] = list(T)
        ans.append(Z)
        UnCheck = False

if UnCheck:
    print("UNRESTORABLE")
    sys.exit()
else:
    for a in ans:
        x = ("".join(a)).replace("?", "a")
        o.append(x)

o.sort()
print(o[0])
        
        
            

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int main() {
    int N, A, cnt = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (A % 2) cnt++;
    }
    cout << (cnt % 2 ? "NO" : "YES") << endl;
}

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

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

		while((str=br.readLine()) != null){
			int n = Integer.parseInt(str);
			int count = 0;
			int prime[] = new int[n+1];


				for(int i=2; i<=n; i++){
					if(prime[i]==0){
						for(int j=i*2; j<=n; j = j+i){
							prime[j]=1;
						}
					}
				}
				for(int i=2; i<=n; i++){
					if(prime[i]==0){
						count++;
					}
				}

			System.out.println(count);
		}
	}
}

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

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

void solve() {
    ll H; cin >> H;
    int N; cin >> N;
    vector<int> A(N); rep(i, N) cin >> A[i];

    ll max_attack = accumulate(A.begin(), A.end(), 0);

    if(H > max_attack){
        cout << "No" << "\n";
    }else{
         cout << "Yes" << "\n";
    }

}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl();
    ll test=1;
    ll mod=1e9+7;
    for(ll i=2;i<=n;i++)
        (test*=i)%=mod;
    cout<<test<<endl;
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    long long ans = 0;
    for(int i=1;i<n;i++){
        if(a[i] < a[i-1]){
            ans += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4368
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;
char f[502][502];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int n,m;
bool erase(vector<pair<int,int> > pos){
    bool reachable[2][502][502];
    memset(reachable, false, sizeof(reachable));
    int x,y;
    
    for(int i=0;i<2;i++){
        for(int j=0;j<4;j++){
            y = pos[i].first;
            x = pos[i].second;
            do{
                y += dy[j];
                x += dx[j];
                if(f[y][x] == '.'){
                    reachable[i][y][x] = true;
                }else{
                    break;
                }
            }while(f[y][x] == '.');
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(reachable[0][i][j] && reachable[1][i][j]){
                return true;
            }
        }
    }
    return false;
}

int main(){

    cin >> m >> n;
    vector<pair<int,int> > place[26];

    memset(f, -1, sizeof(f));
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            cin >> f[i][j];
            if(f[i][j] == '.') continue;
            place[f[i][j] - 'A'].push_back(make_pair(i,j));
        }
    }

    int ret=0;
    bool isended = false;
    while(!isended){
        isended = true;
        for(int i=0;i<26;i++){
            if((int)place[i].size() != 0){
                if(erase(place[i])){
                    ret += 2;
                    isended = false;
                    f[place[i][0].first][place[i][0].second] = '.';
                    f[place[i][1].first][place[i][1].second] = '.';
                    place[i].clear();
                }
            }
        }
    }
    cout << ret << endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007
int main()
{
  int n;
  cin >> n;
  vector<vector<char>> s(2,vector<char>(n));
  int i,j;
  rep(i,2)rep(j,n) cin >> s[i][j];
  vector<ll> dp(n+1,0);
  dp[0] = 1;
  int bef = 0;
  vector<int> sel={6,2,3};
  rep(i,n)
  {
    if(s[0][i] == s[1][i])
    {
      dp[i+1] = dp[i]*(3-bef);
      dp[i+1] %= MOD;
      bef = 1;
    }
    else
    {
      dp[i+1] = dp[i]*sel[bef];
      dp[i+1] %= MOD;
      dp[i+2] = dp[i+1];
      bef = 2;
      i++;
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<ll> a(100);
  a[0] = 2, a[1] = 1;
  for (int i = 2; i < 100; i++) a[i] = a[i-1] + a[i-2];

  cout << a[n] << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize
    }
    let mut a = 0;
    for i in 0..n {
        let m = i + 1;
        if m % 2 == 0 {continue;}
        let mut c = 0;
        for k in 0..m {
            if m % (k + 1) == 0 {
                c += 1;
            }
        }
        if c > 7 {
            a += 1;
        }
    }
    println!("{}", a);
}


Measured memory_bytes: 4352
//  RAKSHIT KADAM
 #include <bits/stdc++.h>
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
 #warning !!!check the size of arrayss!!!
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define newMOD  998244353
 #define MAX 300006
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define INF 2000000000000000005

 #define vi vector<ll>
#define pi 3.1415926535897932384626433832795
#define Endl endl
#define lb lower_bound
#define ub upper_bound

using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
 //ddfdsfdfs

//ll modInverse(int a, int m){ return power(a, m-2, m);} // if a and m are relativelyprime
ll Count[MAX];
ll lim[MAX];
vi v[MAX];
void solve()
{
    string s;cin>>s;
    reverse(s.begin(),s.end());
    map<ll,ll>m;
    m[0]=1;
    ll ten=1;ll rem=0;
    for(auto it:s)
    {
        ll k=it-'0';
        
        k=(k*ten+rem)%2019;
        
        ten*=10;
        ten%=2019;
        rem=k;
        m[k]++;
    }
    ll ans=0;
    for(auto it:m)
    {
        ans+=((it.second)*(it.second-1))/2;
    }
    cout<<ans<<endl;
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }


 solve();
    return 0;
}


Measured memory_bytes: 10772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>
#include <map>

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

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

    ll N;
    cin>>N;
    map<ll, ll> as;
    for (ll n = 0; n < N; n++) {
        ll a;
        cin>>a;
        as[a]++;
    }

    ll ans = 0;
    for (auto&& a : as) {
        if (a.first <= a.second) ans += a.second - a.first;
        else ans += a.second;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 6272
#include <stdio.h>

int main(){
	int a,b;
	int flag  = 1;
	scanf("%d %d",&a,&b);		
	char s[a+b+5];
	scanf("%s",s);
	s[a] != '-' ? flag = 0 : flag  = 1;
	for(int i=0;s[i]!='\0';i++){
			if(i!=a){
				if(s[i]<'0' || s[i]>'9'){
					flag = 0;
				}
			
			}
		}
		flag==1 ? puts("Yes") : puts("No");
 	return 0;
}

Measured memory_bytes: 3168
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

const int MAX_V = 100000;
struct edge { int to, cost; };
int k;
vector<edge> G[MAX_V];
int d[MAX_V];
void bfs01(int s) {
	deque<pair<int, int>> que;
	fill(d, d + k, INF);
	d[s] = 0;
	que.push_back(mp(0, s));
	while (!que.empty()) {
		pair<int, int> p = que.front(); que.pop_front();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				if (e.cost == 0)que.push_front(mp(d[e.to], e.to));
				else que.push_back(mp(d[e.to], e.to));
			}
		}
	}
}
int main() {
	cin >> k;
	REP(i, k) {
		edge t;
		t.to = (i + 1) % k;
		t.cost = 1;
		G[i].emplace_back(t);
	}
	REP(i, k) {
		edge t;
		t.to = (i * 10) % k;
		t.cost = 0;
		G[i].emplace_back(t);
	}
	bfs01(1);
	cout << d[0] + 1 << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,t,ans = INF; cin >> n >> t;
    rep(i,n){
        int c,time; cin >> c >> time;
        if(t >= time) ans = min(ans,c);
    }
    if(ans == INF){
        OUT("TLE");
        return 0;
    }
    ANS;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long

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

	if(a*b%2==0)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Topic02
{
    class ALDS1_2_A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            int[] A = ReadLine().Split()
                .Select(n => int.Parse(n)).ToArray();

            bool flag = true;
            int result = 0;
            while (flag)
            {
                flag = false;
                for (int j = N - 1; j >= 1; j--)
                {
                    if (A[j] < A[j - 1])
                    {
                        int tmp = A[j];
                        A[j] = A[j - 1];
                        A[j - 1] = tmp;
                        result++;
                        flag = true;
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < N; j++)
            {
                sb.Append(A[j].ToString() + " ");
            }
            WriteLine(sb.Remove(sb.Length - 1, 1));
            WriteLine(result.ToString());
            ReadKey();
        }
    }
}



Measured memory_bytes: 18348
a, b = map(int, input().split())
l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if l.index(a) > l.index(b):
  print("Alice")
elif l.index(a) < l.index(b):
  print("Bob")
else:
  print("Draw")

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

using namespace std;


int main() {
    int N;
    int A[300];

    cin >> N;
    for (int i=0; i<N; i++) cin >> A[i];
    int cnt = -1;
    bool isCon = true;
    while(isCon) {
        cnt++;
        for (int i=0; i<N; i++) {
            if (A[i]%2 == 0) {
                A[i] = A[i]/2;
            } else {
                isCon = false;
                break;
            }
        }
    }
    cout << cnt << endl;
}

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

using Lint=long long;

class Permutation
{
 private:
   vector<int> A;
 public:
   Permutation(int n):A(n){}
   int& operator[](int i){ return A[i]; }
   int size(){ return A.size(); }
   static Permutation I(int n){
      Permutation res(n);
      for(int i=0;i<n;i++) res[i]=i;
      return res;
   }

   Permutation& operator*=(Permutation& B){
      vector<int> C(size());
      for(int i=0;i<size();i++) C[i]=B[A[i]];
      A.swap(C);
      return *this;
   }
   Permutation operator*(Permutation& B){ return Permutation(*this)*=B; }
   Permutation pow(Lint K){
      Permutation res=Permutation::I(size());
      Permutation B=*this;
      while(K>0){ if(K&1) res*=B; B*=B; K>>=1; }
      return res;
   }
};

int main()
{
   int N; cin>>N;
   vector<int> x(N);
   for(int i=0;i<N;i++) cin>>x[i];
   int M; cin>>M;
   Lint K; cin>>K;
   vector<int> a(M);
   for(int i=0;i<M;i++) cin>>a[i],a[i]--;

   const int sz=N-1;
   vector<int> d(sz);
   for(int i=0;i<sz;i++) d[i]=x[i+1]-x[i];

   Permutation p=Permutation::I(sz);
   for(int i=0;i<M;i++){
      swap(p[a[i]-1],p[a[i]]);
   }
   p=p.pow(K);

   vector<Lint> ans(N);
   ans[0]=x[0];
   for(int i=0;i<sz;i++){
      ans[i+1]=ans[i]+d[p[i]];
   }
   for(int i=0;i<N;i++) cout<<ans[i]<<endl;
   return 0;
}


Measured memory_bytes: 3796
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

huga=[1]
for i in range(100):
  huga.append(huga[-1]+i+2)
n=int(input())
hoge=factorization(n)
ans=0
for i in range(len(hoge)):
  for j in range(len(huga)):
    if(hoge[i][1]>=huga[j]):
      ans+=1
      
if(n==1):
  print(0)
else:
  print(ans)

Measured memory_bytes: 9504
// ABC050B - 

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

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

int main() {
	int N;
	cin >> N;
	int sum = 0;
	int T[N];
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		sum += T[i];
	}
	int M;
	cin >> M;
	int P[M], X[M];
	for (int i = 0; i < M; i++) {
		cin >> P[i] >> X[i];
	}

	for (int i = 0; i < M; i++) {
		cout << sum - T[P[i]-1] + X[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL n;
LL dp[25][1 << 21] = {0};
LL a[25][25];

LL countone(LL x){
	LL cnt = 0;
	while(x){
		if(x & 1) cnt ++;
		x >>= 1;
	}
	return cnt;
}

LL cnt[1 << 21];

int main(){
	dp[0][0] = 1;
	scanf("%lld",&n);
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			scanf("%lld",&a[i][j]);
		}
	}
	for(LL s = 0;s < (1 << n);s ++) cnt[s] = countone(s);
	for(LL i = 1;i <= n;i ++){
		for(LL s = 0;s < (1 << n);s ++){
			if(cnt[s] != i) continue;
			for(LL j = 1;j <= n;j ++){
				if(((s >> (j - 1)) & 1) && a[i][j]) dp[i][s] += dp[i - 1][s ^ (1 << (j - 1))];
				dp[i][s] %= N;
			}
		}
	}
	printf("%lld\n",dp[n][(1 << n) - 1]);
	return 0;
}
//

Measured memory_bytes: 329984
n = int(input())
lis = list(map(int,input().split()))
lis[0]-=1
for i in range(n-1):
  if lis[i] < lis[i+1]:
    lis[i+1] -= 1
  elif lis[i] > lis[i+1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int N,M; cin>>N>>M;
	cout<<(N==1 or M==1 ? (N==1 and M==1 ? 1 : max(N,M)-2) : (N-2)*(M-2))<<endl;
}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  ll mod = 1e9+7;
  int n; cin >> n;
  vector<ll> a(n);
  vector<ll> s(n+1);
  for(int i=0; i<n; ++i) {
    cin >> a.at(i);
    s.at(i+1) = s.at(i) + a.at(i);
  }
  
  ll ans = 0;
  for(int i=0; i<n; ++i) {
    ans += ((__int128_t)(a.at(i))*(__int128_t)(s.at(n)-s.at(i+1)))%mod;
  }
  cout << (ans+mod)%mod << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n;cin>>n;
    map<string, int> ma;
    rep(i,n){
        string t;cin>>t;
        ma[t]++;
    }
    printf("AC x %d\n", ma["AC"]);
    printf("WA x %d\n", ma["WA"]);
    printf("TLE x %d\n", ma["TLE"]);
    printf("RE x %d\n", ma["RE"]);
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

constexpr ll LNF = 1ll<<60;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int solve(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,0,n){
        cin >> a[i];
    }
    string s; cin >> s;
    vector<ll> base;
    rrep(i,0,n){
        if(s[i]=='0'){
            for(ll b: base){
                chmin(a[i],a[i]^b);
            }
            if(a[i]>0){
                base.emplace_back(a[i]);
            }
        }
        else{
            for(ll b: base){
                chmin(a[i],a[i]^b);
            }
            if(a[i]>0){
                cout << 1 << endl;
                return 0;
            }
        }        
    }
    cout << 0 << endl;
    return 0;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    rep(i,0,t){
        solve();
    }
}

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

int main() {

    int h, w;

    for ( ;; ) {

        std::cin >> h >> w;

        if ( h == 0 && w == 0 ) break;

        for ( int i = 0; i < h; i++ ) {

            for ( int j = 0; j < w; j++ ) std::cout << "#";
            std::cout << std::endl;
        }

        std::cout << std::endl;
    }


    return 0;
}



Measured memory_bytes: 3092
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) n
    allocate(x(n),y(n))
    read(*,*)x
    if(mod(n,2)==0)then
        do i=1,n/2
            y(i)=x(n+2-2*i)
            y(i+n/2)=x(i*2-1)
        end do
    else
        do i=1,n/2+1
            y(i)=x(n+2-2*i)
        end do
        do i=1,n/2
            y(n/2+1+i)=x(i*2)
        end do
    end if
    write(*,*)y

    stop
end program sample
  



Measured memory_bytes: 9464
#include <algorithm>
#include <iostream>
#include <utility>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    string s; cin >> s;
    int q; cin >> q;
    string t;

    REP(i, q) {
        int type; cin >> type;
        if (type == 1) swap(s, t);
        else {
            int f; cin >> f;
            char c; cin >> c;
            if (f == 1) t += c;
            else s += c;
        }
    }

    reverse(t.begin(), t.end());
    cout << t << s << endl;
    return 0;
}


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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second

Int INF = 1e9;
Int mod = 1e9+7;

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

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define NMAX 1000003
#define TMAX 3


int vacSolve(int list[NMAX][TMAX],int n){
  int dp[NMAX][TMAX] = {0};
  dp[0][0] = list[0][0];
  dp[0][1] = list[0][1];
  dp[0][2] = list[0][2];
  for(int i=1;i<n;i++){
    dp[i][0] = max(dp[i-1][1] + list[i][0],dp[i][0]);
    dp[i][0] = max(dp[i-1][2] + list[i][0],dp[i][0]);
    dp[i][1] = max(dp[i-1][0] + list[i][1],dp[i][1]);
    dp[i][1] = max(dp[i-1][2] + list[i][1],dp[i][1]);
    dp[i][2] = max(dp[i-1][0] + list[i][2],dp[i][2]);
    dp[i][2] = max(dp[i-1][1] + list[i][2],dp[i][2]);
  }
  
  int result = max(dp[n-1][0],dp[n-1][1]);
  result = max(result,dp[n-1][2]);
  return result; 
}

int main() {
  int n,temp;
  int list[NMAX][TMAX];
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin >> temp;
      list[i][j] = temp;  
    }                        
  }
  printf("%d",vacSolve(list,n));
  return 0;      
}

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

int main(){
	int h, w;
	while(cin >> h >> w){
		string in;
		for (int i = 0; i < w + 2;i++) {
			cout << "#";
		}
		cout << endl;
		for(int i = 0;i<h;i++){
			cin >> in;
			cout << "#" << in << "#" << endl;
		}
		for (int i = 0; i < w + 2;i++) {
			cout << "#";
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];

  sort(a.begin(), a.end());

  cout << a.back() - a[0] << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> p(n+1);
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            p[j]++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ans += i * p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 81368