akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  
  for(int i=0;i<K;i++){
    vector<int> s(N+1);
    for(int j=0;j<N;j++){
      s[max(0,j-A[j])]++;
      s[min(N,j+A[j]+1)]--;
    }
    int cur=0;
    int tmp=N;
    for(int j=0;j<N;j++){
      cur+=s[j];
      A[j]=cur;
      tmp=min(tmp,cur);
    }
    if(tmp==N) break;
  }

  for(int i=0;i<N;i++){
    cout << A[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4840
#入力
N, Y = map(int, input().split())


def judge(N, Y):
    for x in range(0, N+1):
        for y in range(0,N-x+1):
            a = Y - (10000 * x + 5000 * y) #残額
            z = a // 1000
            if x + y + z == N:
                return x, y, z
    return -1, -1, -1

lst =list(judge(N, Y))
ans = str(lst[0]) + ' ' + str(lst[1]) + ' ' + str(lst[2])

print (ans)

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

int dp[100005];
int main(){
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);
    for(int i=2;i<n;i++){
        dp[i]=min((dp[i-1]+(abs(ar[i]-ar[i-1]))),(dp[i-2]+(abs(ar[i]-ar[i-2]))));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#define maxn 100010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
struct P{
    int x,y;
}a[maxn],b[maxn*2];
int cnt,res;
bool cmp(P a,P b)
{
    if(a.x!=b.x)  return a.x<b.x;
    return a.y<b.y;
}
bool operator < (P a,P b)
{
    if(a.x!=b.x)  return a.x<b.x;
    return a.y<b.y;
}
int id[maxn*4];
int head[maxn*4],nxt[maxn*40],to[maxn*40],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
void build(int k,int l,int r)
{
    if(l==r)
    {
        id[k]=b[l].y;
        return;
    }
    id[k]=++cnt;
    int mid=(l+r)/2;
    build(k*2,l,mid);
    build(k*2+1,mid+1,r);
    add(id[k],id[k*2]);
    add(id[k],id[k*2+1]);
}
void find(int k,int l,int r,int x,int y,int z)
{
    if(x>y)  return;
    if(l>=x&&r<=y)
    {
        add(z,id[k]);
        return;
    }
    int mid=(l+r)/2;
    if(mid>=x)  find(k*2,l,mid,x,y,z);
    if(mid<y)   find(k*2+1,mid+1,r,x,y,z);
}
void work(int x,int mid,int y,int z)
{
    int L=lower_bound(b+1,b+2*n+1,(P){x-mid+1,0})-b;
    int R=upper_bound(b+1,b+2*n+1,(P){x+mid-1,2*n+1})-b-1;
    int MID=lower_bound(b+1,b+2*n+1,(P){x,y})-b;
    find(1,1,2*n,L,MID-1,z);
    find(1,1,2*n,MID+1,R,z);
}
stack<int>s;
int dfn[maxn*4],low[maxn*4],vis[maxn*4],D;
int cnt_scc,scc[maxn*4];
void tarjan(int x)
{
    dfn[x]=low[x]=++D;
    vis[x]=1;s.push(x);
    for(int i=head[x];i;i=nxt[i])
    {
        if(!dfn[to[i]])
        {
            tarjan(to[i]);
            low[x]=min(low[x],low[to[i]]);
        }
        else if(vis[to[i]])
        {
            low[x]=min(low[x],dfn[to[i]]);
        }
    }
    if(dfn[x]==low[x])
    {
        cnt_scc++;
        int tmp=0;
        while(tmp!=x)
        {
            tmp=s.top();s.pop();
            scc[tmp]=cnt_scc;
            vis[tmp]=0;
        }
    }
}
bool check(int x)
{
    tot=0;cnt=2*n;D=0;cnt_scc=0;
    memset(scc,0,sizeof(scc));
    memset(head,0,sizeof(head));
    memset(dfn,0,sizeof(dfn));
    memset(low,0,sizeof(low));
    build(1,1,2*n);
    for(int i=1;i<=n;i++)
    {
        work(a[i].x,x,i,i+n);
        work(a[i].y,x,i+n,i);
    }
    for(int i=1;i<=cnt;i++)
      if(!dfn[i])  tarjan(i);
    for(int i=1;i<=n;i++)
      if(scc[i]==scc[i+n])  return false;
    return true;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  a[i].x=read(),a[i].y=read();
    for(int i=1;i<=n;i++)  b[i*2-1].x=a[i].x,b[i*2].x=a[i].y;
    for(int i=1;i<=n;i++)  b[i*2-1].y=i,b[i*2].y=i+n;
    sort(b+1,b+2*n+1,cmp);
    int l=0,r=1000000000;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
            res=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  1e9
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))


signed main(){ INIT;
    VAR(ll, n);
    MAT(int, f, n, 10);
    MAT(int, p, n, 11);

    int ans = -INF;
    FOR(i, 1, 1<<10){
        int sum = 0;
        REP(s, n){
            int o = 0;
            REP(t, 10) o += (i>>t&1) & f[s][t];
            sum += p[s][o];
        }
        ans = max(sum, ans);
    }
    OUTL(ans);
RET;}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    vector<int> lds(n, -1);
    for (int i = 0; i < n; ++i) {
        auto it = lower_bound(lds.rbegin(), lds.rend(), a[i]);
        *(it-1) = a[i];
    }
    auto it = upper_bound(lds.rbegin(), lds.rend(), -1);
    int ans = n - (it - lds.rbegin());

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main{
	public static void main (String args[]){
		Scanner sc=new Scanner(new InputStreamReader(System.in));
		while(true){
			int h=sc.nextInt();
			int w=sc.nextInt();
			if(h==0&&w==0) break;
			for(int i=0;i<w;i++) System.out.print("#");	
			System.out.println("");
			for(int i=2;i<=h-1;i++){
				System.out.print("#");
				for(int j=2;j<=w-1;j++) System.out.print(".");
				System.out.print("#");
				System.out.println("");
			}
			for(int i=0;i<w;i++) System.out.print("#");
			System.out.println("");
			System.out.println("");
		}
		sc.close();
	}
}

Measured memory_bytes: 32556
n,k=gets.split.map &:to_i
a=gets.split.map &:to_i
r=0
n.times do |i|
  r+=a[i] if a[i]>0
end
m=0
gp=0
gm=0
k.times do |j|
  if a[j]>=0
    gp+=a[j]
  else
    gm-=a[j]
  end
end
m=[gp.abs,gm.abs].min.abs
mi=0
(n-k).times do |i|
  if a[i]>=0
    gp-=a[i]
  else
    gm+=a[i]
  end
  if a[i+k]>=0
    gp+=a[i+k]
  else
    gm-=a[i+k]
  end
  if gp.abs<=m
    m=gp.abs
    mi=i
  end
  if gm.abs<=m
    m=gm.abs
    mi=i
  end
end
p r-m

Measured memory_bytes: 8724
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    string S, T;
    int A, B;
    string U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (S == U) A--;
    else B--;
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
// #define ONLINE_JUDGE
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
inline void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    int hs[h + 1];
    int ws[w + 1];
    fill(hs, hs + h + 1, 0);
    fill(ws, ws + w + 1, 0);
    set<pair<int, int>> ss;
    for (int i =  0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        hs[x]++;
        ws[y]++;
        ss.insert({x, y});
    }
    int mx = -1, my = -1;
    for (auto x : ws) {
        mx = max(mx, x);
    }
    for (auto y : hs) {
        my = max(my, y);
    }
    vi maybex, maybey;
    for (int i = 0; i <= w; i++) {
        if (ws[i] == mx) {
            maybex.pb(i);
        }
    }
    for (int i = 0; i <= h; i++) {
        if (hs[i] == my) {
            maybey.pb(i);
        }
    }
    for (auto x : maybex) {
        for (auto y : maybey) {
            if (!ss.count({y, x})) {
                cout << mx + my;
                return ;
            }
        }
    }
    cout << mx + my - 1;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 34904
#include <cstdio>
#include <algorithm>	
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vi; 



int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("out.txt", "w", stdout);
#endif
	int a, b;
	cin >> a >> b;
	for(int i = 1; i <= 3; ++i) {
		if(i != a && i != b) {
			cout << i << endl;
			return 0;
		}
	}	
	return 0;
}

Measured memory_bytes: 256
a = gets.to_i
# b = gets.to_i
s = gets.chomp
# s,t = gets.split.map(&:to_s)
# n= gets.split.map(&:to_i)

# s = gets.chomp.chars.uniq
# puts gets.chomp.chars.uniq.size != 1 ? "Yes" : "No"
puts a>=3200 ? s : "red"

Measured memory_bytes: 1788
using System;
using System.Linq;
class Program
{
static void Main(string[] argv)
{
var v1 = Console.ReadLine();
var v2 = Console.ReadLine();

Console.WriteLine(
v1.Where((i,x)=>i==v2[x]).Count()
);
v1=null;
v2=null;
return;
}
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define ll long long
#define amaterasu ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
    amaterasu
    int n, h, s=0;
    cin >> h >> n;
    while(n--)
    {
        int t;
        cin >> t;
        s += t;
    }
    cout << ((s >= h) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
//奇数長の閉路を持たない ⇔ 2部グラフ。という有名事実によって、解けることはすぐに分かるけど、実装が大変なのであった。
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
vector<int> et[100000];
vector<int> ec[100000];
int color[100000];
int value[100000];

bool isBinary() {
	int i;
	
	rep(i, n) color[i] = -1;
	queue<int> que;
	que.push(0);
	color[0] = 0;
	value[0] = 0;
	while (!que.empty()) {
		int v = que.front(); que.pop();
		rep(i, et[v].size()) {
			int nv = et[v][i];
			if (color[nv] == -1) {
				color[nv] = !color[v];
				value[nv] = ec[v][i] - value[v];
				que.push(nv);
			}
			else if (color[nv] == color[v]) {
				return false;
			}
		}
	}
	return true;
}

int INF = 1e+10;

signed main() {
	int i, j;
	
	cin >> n >> m;
	rep(i, m) {
		int u, v, s;
		cin >> u >> v >> s;
		u--; v--;
		et[u].push_back(v);
		et[v].push_back(u);
		ec[u].push_back(s);
		ec[v].push_back(s);
	}
	
	bool res = isBinary();
	
	if (res) {	//2部グラフなら, 頂点値は辺の条件に依存しない。
		rep(i, n) {
			rep(j, et[i].size()) {
				if (value[i] + value[et[i][j]] != ec[i][j]) {
					cout << 0 << endl;
					return 0;
				}
			}
		}
		
		//頂点0に書く値の下限low, 上限highを考える。[low, high]
		int low = 1;
		rep(i, n) if (color[i] == 0) low = max(low, 1 - value[i]);
		
		int high = INF;
		rep(i, n) if (color[i] == 1) high = min(high, value[i] - 1);
		
		cout << max(0LL, high - low + 1) << endl;
		return 0;
	}
	
	//非2部グラフなら, 頂点に書く値は一意。同じカラーの2頂点を見れば、頂点0に書くべき値が分かる。
	int findV, rootVal;
	
	rep(i, n) {
		if (color[i] == -1) continue;
		rep(j, et[i].size()) {
			if (color[et[i][j]] == -1) continue;
			if (color[i] == color[et[i][j]]) {
				findV = i;
				int val = ec[i][j] - (value[i] + value[et[i][j]]);
				
				//cout << "find! -> " << i << " " << et[i][j] << ", color = " << color[i] << endl;
				if (color[i] == 0) rootVal = val / 2;
				if (color[i] == 1) rootVal = -val / 2;
				break;
			}
		}
		if (j < et[i].size()) break;
	}
	
	//rep(i, n) { cout << color[i] << " " << value[i] << endl; }
	//cout << "findV, rootVal = " << findV << ", " << rootVal << endl;
	
	//実際に書いていく。
	queue<int> que;
	static bool visit[100000] = {false};
	
	que.push(0);
	value[0] = rootVal;
	visit[0] = true;
	
	while (!que.empty()) {
		int v = que.front(); que.pop();
		rep(i, et[v].size()) {
			int nv = et[v][i];
			if (!visit[nv]) {
				value[nv] = ec[v][i] - value[v];
				visit[nv] = true;
				que.push(nv);
			}
		}
	}
	
	//辺, 頂点値のチェック
	rep(i, n) {
		rep(j, et[i].size()) {
			if (value[i] + value[et[i][j]] != ec[i][j]) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	
	rep(i, n) if (value[i] <= 0) { cout << 0 << endl; return 0; }
	
	cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 15080
from math import cos, pi, sqrt
A, B, H, M = map(int, input().split())
theta = abs(((H + M / 60) % 12) / 6 - (M % 60) / 30) * pi
print(sqrt(A ** 2 + B ** 2 - 2 * A * B * cos(min(360 - theta, theta))))

Measured memory_bytes: 9572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> dP;

const int INF = 100000000;
const double EPS = 1e-10;

vector<vector<double> > edge;
double dist(P &a, P &b){
	return sqrt(double(a.X-b.X)*(a.X-b.X)+(a.Y-b.Y)*(a.Y-b.Y));
}

bool dfs(vector<P> &c, bitset<20> &b, int hi, int di, double t){
	if(edge[hi][di] <= t+EPS) return false;
	if(b.count() == 20) return true;
	rep(i, c.size()-2){
		if(b[i]) continue;
		if(edge[i][di] <= t+edge[i][hi]+EPS) return false;
	}
	rep(i, c.size()-2){
		if(b[i]) continue;
		b[i] = true;
		if(dfs(c, b, i, di, t+edge[i][hi])) return true;
		b[i] = false;
	}

	return false;
}

int main(){
	while(1){
		int n;
		cin >> n;
		if(!n)break;
		P h, d;
		cin >> h.X >> h.Y >> d.X >> d.Y;
		vector<P> c(n);
		rep(i, n){
			cin >> c[i].X >> c[i].Y;
		}
		bitset<20> bits;
		bits = ~bits;
		rep(i, n){
			bits[i] = false;
		}
		c.push_back(h);
		c.push_back(d);
		edge.resize(n+2);
		rep(i, n+2){
			edge[i].resize(n+2);
		}
		rep(i, n+2){
			for(int j = i; j < n+2; j++){
				if(i == j){
					edge[i][j] = 0;
					continue;
				}
				edge[i][j] = edge[j][i] = dist(c[i], c[j]);
			}
		}

		cout << (dfs(c, bits, n, n+1, 0)?"YES":"NO") << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#pragma GCC optimize(3)
#pragma GCC optimize("inline")
#pragma once
#include<bits/stdc++.h>
#define q register
#define qsize 1<<12
typedef long long ll;
using namespace std;
ll n,li,ri,ans;
inline ll qread()
{
	q char ch=getchar();
	q ll v=0;
	while(ch<'0'||ch>'9')   ch=getchar();
	while(ch>='0'&&ch<='9'){
		v=v*10+ch-'0';
		ch=getchar();
	}
	return v;
}
inline void qwrite(ll v)
{
	if(v>9)   qwrite(v/10);
	putchar(v%10+'0');
}
int main()
{
	n=qread();
	while(n--){
		li=qread();
		ri=qread();
		ans+=ri-li+1;
	}
	qwrite(ans);
		putchar('\n');
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


lim = 2*10**5   #必要そうな階乗の限界を入力

#階乗#
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod


H, W, A, B = MAP()

ans = 0
for n in range(B, W):
	way = C(H-A-1+n, n)*C(W-n-1+A-1, A-1)%mod
	ans = (ans+way)%mod

print(ans)

Measured memory_bytes: 20952
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	string s,t;
	cin >> s >> t;
	
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	
	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a,const void *b)
{return *(int *)a-*(int *)b;}

int main(){
  int N,M;
  int A,S[100001]={0};
  long long int n=1,sum=0;
  scanf("%d %d",&N,&M);
  for(int i=0;i<N;i++){
    scanf("%d",&A);
    S[i+1]=(S[i]+A)%M;
  }
 
  qsort(S,N+1,sizeof(int),cmp);
  for(int i=1;i<=N;i++)
    if(S[i]==S[i-1])
      n++;
    else
      if(n!=1){
	sum+=n*(n-1)/2;
	n=1;
      }
	sum+=n*(n-1)/2;
	printf("%lld\n",sum);
	return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int y;
  int i=0;
  string s;
  int N;
  
  cin >> N;
  
  while(i<N){
    cin >> s;
    
    if(s=="Y"){
      cout << "Four" << endl;
      break;
    }
    
    i++;
  }
  
  if(i==N)
    cout << "Three" << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse::<T>().ok().unwrap()
}

fn main() {
    let x: u32 = read();
    let a: u32 = read();
    let b: u32 = read();
    let ans = (x - a) - ((x - a) / b) * b ;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
void Traveling() {
	int N;
	cin >> N;
	int pt = 0,px = 0, py = 0;

	for (size_t i = 0; i < N; i++)
	{
		int t, x, y;
		cin >> t >> x >> y;
		int it = t - pt;
		int ix = abs(x - px);
		int iy = abs(y - py);
		if (it - ix - iy < 0) {
			cout << "No" << endl;
			return;
		}
		else if((it - ix - iy) % 2 != 0){
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}
int main() {
	Traveling();
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n,k,q = input().split()
n = int(n)
k = int(k)
q = int(q)
correct = [int(input()) for index in range(q)]
count = np.bincount(np.array(correct))

count_extend = np.append(count,np.zeros(n-count.size+1))
count_extend = count_extend[1:]
candidates = np.full(n,k-q)
winner = candidates + count_extend

for value in winner:
  if value>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 19948
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
h = []
used = set()
used.add((0, 0, 0))
heappush(h, (-(A[0]+B[0]+C[0]), 0, 0, 0))
for i in range(K):
    val, x, y, z = heappop(h)
    print(-val)
    if x < X-1 and (x+1, y, z) not in used:
        used.add((x+1, y, z))
        heappush(h, (-(A[x+1]+B[y]+C[z]), x+1, y, z))
    if y < Y-1 and (x, y+1, z) not in used:
        used.add((x, y+1, z))
        heappush(h, (-(A[x]+B[y+1]+C[z]), x, y+1, z))
    if z < Z-1 and (x, y, z+1) not in used:
        used.add((x, y, z+1))
        heappush(h, (-(A[x]+B[y]+C[z+1]), x, y, z+1))



Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int N, x, y; cin>>N>>x>>y;
    ll ans[N];
    for(int i=0; i<N; i++){
        ans[i]=0;
    }
    int s;
    for(int i=1; i<N; i++){
        for(int j=i+1; j<=N; j++){
            if(i<=x){
                if(j<=x){
                    s=j-i;
                }
                else if(j<y){
                    s=min(j-i, x+y-i-j+1);
                }
                else{
                    s=x-y-i+j+1;
                }
            }
            else if(i<y){
                if(j<y){
                    s=min(j-i, -x+y+i-j+1);
                }
                else{
                    s=min(j-i, -x-y+i+j+1);
                }
            }
            else{
                s=j-i;
            }
            ans[s]++;
        }
    }

    for(int i=1; i<N; i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N; cin >> N;
	cout << 180 * (N - 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=100005;
struct subset
{
    int parent;int rank;
};
subset subsets[N+1];
int find(int i)
{
    if(subsets[i].parent==i)
        return i;
    subsets[i].parent=find(subsets[i].parent);
    return subsets[i].parent;
}
void Union(int x,int y)
{
    if(subsets[x].rank>subsets[y].rank)
    {
        subsets[y].parent=x;
    }
    else if(subsets[y].rank>subsets[x].rank)
    {
        subsets[x].parent=y;
    }
    else
    {
        subsets[y].parent=x;
        subsets[x].rank++;
    }
}
bool compare1(pair<int,int>&p1,pair<int,int>&p2)
{
    return p1.fi<p2.fi;
}

void solve()
{

    int n;
    cin>>n;
    pair<int,int>p[n];vector<pair<int,pair<int,int> > > edge;
    for(int i=0;i<=n;i++)
    {
        subsets[i].parent=i;subsets[i].rank=0;
    }
    for(int i=0;i<n;i++)
    {
        cin>>p[i].first>>p[i].second;
    }
    sort(p,p+n,compare1);
    for(int i=1;i<n;i++)
    {
        edge.pb(m1(abs(p[i].first-p[i-1].first),m1(i,i-1)));
    }
    for(int i=0;i<n;i++)
    {
        p[i].first=p[i].second;
        p[i].second=i;
    }
    sort(p,p+n,compare1);
    for(int i=1;i<n;i++)
        edge.pb(m1(abs(p[i].first-p[i-1].first),m1(p[i].second,p[i-1].second)));
    sort(edge.begin(),edge.end());
    int u,v,w,x,y;int ans=0;
    for(int i=0;i<edge.size();i++)
    {
        w=edge[i].first;
        u=edge[i].se.fi;v=edge[i].se.se;
        x=find(u);
        y=find(v);
        if(x!=y)
        {
            ans+=w;
            Union(x,y);
        }
    }
    cout<<ans<<endl;
    

}

int32_t main()
{
    IOS;
    
    int t;
    t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11504
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()) {
			int[] cnt = new int[5];
			for(int i = 0; i < 3; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				cnt[a]++; cnt[b]++;
			}
			if(cnt[1] < 3 && cnt[2] < 3 && cnt[3] < 3 && cnt[4] < 3) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
	}
}

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

int main(){
    int N;
    char tmp;
    scanf("%d%c", &N, &tmp);

    int ac = 0, wa = 0, tle = 0, re = 0;
    char s[5];
    for(int i = 0; i < N; i++){
        fgets(s, 5, stdin);
        if(!strcmp(s, "AC\n")) ac++;
        if(!strcmp(s, "WA\n")) wa++;
        if(!strcmp(s, "TLE\n")) tle++;
        if(!strcmp(s, "RE\n")) re++;
    }

    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);

    return 0;
}

Measured memory_bytes: 1776
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 1;
	int gcd = 0;
	
	static int A[MAX] = {};
	static int temp[MAX], temp2[MAX];
	cin>>N;
	
	for(int i = 1; i <= N; i++){ //cout<<i<<endl;
		cin>>A[i];
		gcd = __gcd(A[i],gcd);
		temp[i] = gcd;
		// cout<<temp[i]<<endl;
	}
	gcd = 0;
	for(int i = N; i >= 1; i--){ //cout<<i<<endl;
		gcd = __gcd(A[i],gcd);
		temp2[i] = gcd;
		// cout<<temp2[i]<<endl;
	}
	
	for(int i = 1; i <= N; i++){
		
		ans = max(ans, __gcd(temp[i-1], temp2[i+1]));
	}

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

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

int main()
{
	int n;
	string s;
	
	cin >> n >> s;
	
	string s_1, s_2;
	
	if (n%2 != 0)
	{
		cout << "No" << endl;
		return 0;
	}
	
	for (int i = 0; i < s.size(); ++i)
	{
		if (i >= s.size()/2)
		{
			s_2.push_back(s[i]);
		}
		else
		{
			s_1.push_back(s[i]);
		}
	}
	
	bool flag = false;
	for (int i = 0; i < s.size()/2; ++i)
	{
		if (s_1[i] == s_2[i])
		{
			flag = true;
		}
		else
		{
			flag = false;
			break;
		}
	}
	
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int prime[MAX];//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(200000);
    int X;cin>>X;
    for(int i=X;;i++){
        if(is_prime[i]){
            cout<<i<<endl;
            return 0;
        }
    }
}




Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());



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

  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e-a>k) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
}


Measured memory_bytes: 256
public class Main {

  private static void solve() {

    long x = ni();

    for (long a = -1000; a <= 1000; a++) {
      for (long b = -1000; b <= 1000; b++) {
        long now = a * a * a * a * a - b * b * b * b * b;

        if (now == x) {
          System.out.println(a + " " + b);
          return;
        }
      }
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

typedef long long ll;

int sum(int x){
  int a=0;
  rep(i,6){
    a+=x%10;
    x/=10;
  }
  return a;
}


int main()
{
   int n,ans=100000;
   cin>>n;
   forx(i,1,n/2+1){
     ans=min(ans,sum(i)+sum(n-i));
     }
   cout<<ans<<endl;
     
     
   return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String a = br.readLine();
		String b = br.readLine();
		int l = Math.min(a.length(), b.length());
		System.out.println(a.substring(0, l).equals(b.subSequence(0, l)) ? "Yes" : "No");
	}
}


Measured memory_bytes: 25300
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    ll H,W,h,w;
    ll r=0,b=0;
    string S;
    ll ans = 1e9;
    cin >> H >> W >> h >> w;
    ans = H * W - (h * W) - (H * w) + (h * w);
    cout << ans << endl;
    
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=9999999;i++)
	{
		if(i*a-i+1>=b)
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  // find x s.t. a^x = b
  static T log(T a,T b){
    const T sq=40000;
    unordered_map<T, T> dp;
    dp.reserve(sq);
    Mint res(1);
    for(Int r=0;r<sq;r++){
      if(!dp.count(res.v)) dp[res.v]=r;
      res*=a;
    }
    Mint p=Mint(a).inv().pow(sq);
    res=b;
    for(Int q=0;q<=MOD/sq+1;q++){
      if(dp.count(res.v)){
        T idx=q*sq+dp[res.v];
        if(idx>0) return idx;
      }
      res*=p;
    }
    assert(0);
    return T(-1);
  }

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  using M = Mint<Int>;
  const Int MOD = 13;
  vector<M> dp(13,0);
  dp[0]=M(1);

  Int n=s.size();
  for(Int i=0;i<n;i++){
    vector<M> nx(13,0);
    for(Int j=0;j<13;j++){
      if(s[i]=='?'){
        for(Int k=0;k<10;k++){
          nx[(j*10+k)%MOD]+=dp[j];
        }
      }else{
        nx[(j*10+(s[i]-'0'))%MOD]+=dp[j];
      }
    }
    swap(dp,nx);
  }

  cout<<dp[5]<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

int main(){
  int N; cin >> N;
  string S; cin >> S;
  rep(i,S.size()) cout << (char)('A'+(S[i]+N-'A')%26);
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

 class Main
 {
    static boolean ischeck(char[] xx,char[] yy)
    {
        for(int j=0;j<xx.length;j++)
        {
            if(xx[j]!=yy[j])
                return false;
        }
        return true;
    }
    static int fun(char[] X,char[] Y,int left)
    {
        int flag=0;
        if(X.length==Y.length)
        {
            char[] xx=new char[X.length];
            
            for(int j=0;j<X.length;j++)
            {
                xx[(left+j)%X.length]=X[j];
            }
            if(ischeck(xx,Y))
            {
                return 1;
            }   
        }
        else
            return 0;
        return 0;
    }

    public static void main(String[] args) 
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        String t=sc.next();
        char[] x=s.toCharArray();
        char[] y=t.toCharArray();
        int flag=0;
        for (int i=0;i<s.length() ;i++ ) 
        {
           if (fun(x,y,i)==1) 
           {
                flag=1;
                break;
           }
            else
                flag=0;
        }
        if(flag==1)
            System.out.println("Yes");
        else
            System.out.println("No");
        
    }
}

Measured memory_bytes: 22868
#include <stdio.h>

#define SIZE 250
#define NUM 801

const int Mod = 998244353;

int main()
{
	int i, N, Q;
	char S[200001];
	scanf("%d %d", &N, &Q);
	
	char block[NUM];
	int j, k, l, r, d, q, n = (N - 1) / SIZE, m = N - n * SIZE, flag[NUM];
	long long ans, ans_block[NUM] = {}, fill_block[10], pow[200001];
	for (i = 1, pow[0] = 1; i < N; i++) pow[i] = pow[i-1] * 10 % Mod;
	for (i = 1; i <= 9; i++) {
		for (j = 1, fill_block[i] = i; j < SIZE; j++) fill_block[i] = (fill_block[i] * 10 + i) % Mod;
	}
	for (i = 0; i <= n; i++) {
		block[i] = 1;
		flag[i] = 1;
		if (i < n) ans_block[i] = fill_block[1] * pow[m+(n-i-1)*SIZE] % Mod;
		if (i == n) for (j = 0, ans_block[i] = 0; i * SIZE + j < N; j++) ans_block[i] = (ans_block[i] * 10 + 1) % Mod;
	}
	
	for (q = 1; q <= Q; q++) {
		scanf("%d %d %d", &l, &r, &d);
		l--;
		r--;
		i = l / SIZE;
		if (flag[i] == 1) {
			for (j = i * SIZE; j < N && j < (i + 1) * SIZE; j++) S[j] = block[i];
			flag[i] = 0;
		}
		for (j = l, i = j / SIZE; j <= r && j < (i + 1) * SIZE; j++) {
			ans_block[i] = (ans_block[i] + pow[N-j-1] * (Mod - S[j]) % Mod + pow[N-j-1] * d) % Mod;
			S[j] = d;
		}
		if (j <= r) {
			for (i++; i < r / SIZE; i++) {
				flag[i] = 1;
				block[i] = d;
				ans_block[i] = fill_block[d] * pow[m+(n-i-1)*SIZE] % Mod;
			}
			if (flag[i] == 1) {
				for (j = i * SIZE; j < N && j < (i + 1) * SIZE; j++) S[j] = block[i];
				flag[i] = 0;
			}
			for (j = i * SIZE; j <= r; j++) {
				ans_block[i] = (ans_block[i] + pow[N-j-1] * (Mod - S[j]) % Mod + pow[N-j-1] * d) % Mod;
				S[j] = d;
			}
		}
		
		for (i = 0, ans = 0; i < n; i++) ans += ans_block[i];
		ans = (ans + ans_block[n]) % Mod;
		printf("%lld\n", ans);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> w(n);
    cin >> w;
    int ans = INF;
    rep(i, n) {
        int sum1 = 0, sum2 = 0;
        rep(j, n) {
            if(j <= i) sum1 += w[j];
            else sum2 += w[j];
        }
        chmin(ans, abs(sum1 - sum2));
    }
    printf("%d\n", ans);
}

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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    int n; cin >> n;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    rep(i,n)
    {
        string a; cin >> a;
        if(a == "AC")
            ++ac;
        else if(a == "WA")
            ++wa;
        else if(a == "TLE")
            ++tle;
        else if(a == "RE")
            ++re;
    }
    pri("AC x "+ to_string(ac));
    pri("WA x "+ to_string(wa));
    pri("TLE x "+ to_string(tle));
    pri("RE x "+ to_string(re));

    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    int left;
    for (int i=0; i<n; i++) {
        int h;
        cin >> h;
        if (i == 0)
            left = max(0, h-1);
        else {
            if (left > h) {
                cout << "No" << endl;;
                return 0;
            }
            else if (left < h)
                left = h-1;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N, M = list(map(int, input().split()))
S = input()

m = N
record = []
while True:
    for i in range(M,-1,-1):
        if i == 0:
            print(-1)
            sys.exit()
        if m-i < 0: continue
        if S[m-i] == "0":
            m = m - i
            record.append(str(i))
            if m == 0:
                print(" ".join(reversed(record)))
                sys.exit()
            break




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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
            string[] str = Console.ReadLine().Split(' ');
            int L = int.Parse(str[0]);
            int R = int.Parse(str[1]);
           
            if(R-L >= 2019)
            {
                Console.WriteLine('0');
                return;
            }
            int l = L % 2019;
            int r = R % 2019;
            int ans = 2019;

           // Console.WriteLine($"{l}  {r}");

            for (int i = l; i < r; i++)
            {
                for (int j = i+1; j <= r; j++)
                {
                    ans = Math.Min(ans, ((i * j) % 2019));
                }
            }
            Console.WriteLine(ans);
            Console.ReadLine();

		}
	}
}


Measured memory_bytes: 11092