akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var D = cin.ReadInt;
            switch (D)
            {
                case 25:
                    WriteLine("Christmas");
                    break;
                case 24:
                    WriteLine("Christmas Eve");
                    break;
                case 23:
                    WriteLine("Christmas Eve Eve");
                    break;
                case 22:
                    WriteLine("Christmas Eve Eve Eve");
                    break;
            }
        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
H,W,K = map(int,input().split())
c,ch,cw,a=[],[],[0]*6,0

for _ in range(H):
	t = input()
	c.append(t)
	ch.append(sum([x=='#' for x in t]))
for j in range(W):
	for i in range(H):
		if c[i][j] == '#':
			cw[j] += 1

for i in range(1<<H):
	for j in range(1<<W):
		s,si,sj=0,[],[]
		for d in range(H):
			if i & 1<<d:
				si.append(d)
				s += ch[d]
		for d in range(W):
			if j & 1<<d:
				sj.append(d)
				s += cw[d]
		for p in si:
			for q in sj:
				if c[p][q] == '#':
					s -= 1
		if sum(ch)-s == K:
			a += 1
print(a)

Measured memory_bytes: 73880
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  for(int i = s.size()-2; i >= 0; i--) {
    string str = s.substr(0, i);
    bool test1 = str.size() % 2 == 1;
    if(test1) continue;
    string left = str.substr(0, (str.size()/2));
    string right = str.substr(str.size()/2, str.size()/2);
    if(left == right) {
      z = str.size();
      break;
    }
  }
  OUT(z);
}

Measured memory_bytes: 256
/* Arpit Pandey*/ 

#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdint.h>
using namespace std;
 
#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define test(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
void fast_io()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
#endif
}

void sol()
{
	int x; cin>>x;
	if(x==0)
		cout<<1<<endl;
	else
		cout<<0<<endl;
}
int32_t main()
{
	fast_io();
	//test(t)
	sol();
	//cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int x,y;
    cin >> x >> y;
    cout << x+y/2 << endl;
}

int main() {
    solve();
    return 0;
}


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

namespace ABC163A
{
    class Program
    {
        static void Main(string[] args)
        {
            double R = double.Parse(Console.ReadLine());
            double pi = Math.PI;
            double ans = 2.0 * R * pi;
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 27616
#include <bits/stdc++.h>
using namespace std;
int h[100000];
vector <long long int> dp(100000,INT_MAX);
long n,k;
long long call(long i)
{
	if(i==(n-1))
	return 0;
	if(dp[i]!=INT_MAX)
	return dp[i];
	if(i<=(n-1-k))
	{
	for(int j=1;j<=k;j++)
	dp[i]=min(call(i+j)+abs(h[i+j]-h[i]),dp[i]);
	}
	else
	{
	for(int j=1;j<=(n-1-i);j++)
	dp[i]=min(call(i+j)+abs(h[i+j]-h[i]),dp[i]);
	}
	
	return dp[i];
}
int main() {
	// your code goes here
	//long n;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	cin>>h[i];
	cout<<call(0)<<endl;
	return 0;
	
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}
 
int main() {
 ll N,K;
 cin >> N >> K;
 ll p[N];
 for(int i=0;i<N;i++){
     cin >> p[i];
 }
 
 
 double max = 0;
 double temp = 0;
 for(int i=0;i<K;i++){
     temp+=(((double)p[i]+1.0)/2.0);
     //printf("%lf\n",temp);
 }
 max = temp;
 int maxindex = 0;
 for(int i=0;i+K<N;i++){
     temp -= (((double)p[i]+1.0)/2.0);
     temp += (((double)p[i+K]+1.0)/2.0);
     if(temp>max){
         max = temp;
         maxindex = i;
     }
 
 }
 printf("%.15lf",max);
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
	while(1){
		int w;
		cin >> w;
		if(w==-1)break;
		if(w<=10){
			cout << 4280-1150 << endl;
		}else if(w<=20){
			cout << 4280-1150-((w-10)*125) << endl;
		}else if(w<=30){
			cout << 4280-1150-(10*125)-((w-20)*140) << endl;
		}else{
			cout << 4280-1150-(10*125)-(10*140)-((w-30)*160) << endl;
		}
	}
	return 0;
}

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

int main(){
    int ans=0, a=0, b=0, c=0;
    char tmp;
    string A, B, C;
    cin >> A;
    cin >> B;
    cin >> C;
    tmp = A[0];
    a++;
    while(true){
	if(tmp == 'a'){
	    if(a == A.size()){
		cout << "A" << endl;
		return 0;
	    }
	    tmp = A[a];
	    a++;	    
	}
	else if(tmp == 'b'){
	    if(b == B.size()){
		cout << "B" << endl;
		return 0;
	    }
	    tmp = B[b];
	    b++;	    

	    
	}
	else if(tmp == 'c'){
	    if(c == C.size()){
		cout << "C" << endl;
		return 0;
	    }
	    tmp = C[c];
	    c++;	    
	}
    }
    
}


Measured memory_bytes: 256
N, M, X = map(int,input().split())

c = [0]*N
a = [[0 for i in range(M)] for j in range(N)]


for i in range(N):
    tmp = input().split()
    c[i] = int(tmp[0])
    for l in range(M):
        a[i][l] = int(tmp[l+1])

Pattern = 2**(N)
TotalOld = 1<<60 
Flag = False

for i in range(Pattern):
    Total = 0
    learn = [0]*M
    for b in range(N):
        if (i>>b)&1 == 1:
            Total += c[b]
            for m in range(0,M):
                learn[m] += a[b][m]
    if min(learn) >= X and Total < TotalOld:
        TotalOld = Total
        Flag = True

if Flag:
    print(TotalOld)
else:
    print('-1')
        

Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;//998244353 ;

ll cnt[200020];

int main(){
  int n;
  cin >> n;
  ll a[n];
  ll ans=0;
  rep(i,n){
    cin >> a[i];
    cnt[a[i]]++;
    ans+=a[i];
  }
  int q;
  cin >> q;
  rep(_,q){
    ll b,c;
    cin >> b >> c;
    ans-=b*cnt[b];
    ans+=c*cnt[b];
    cnt[c]+=cnt[b];
    cnt[b]=0;
    cout << ans << endl;
//    rep(i,4)cout << i+1 << ' ' << cnt[i+1] << endl;
  }
return 0;}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	template <typename U>
	explicit operator U() const { return (U)val; }
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	vector<Mint> dp(m + 1, 1);
	vector<Mint> p2(m + 1, 1), invp2(m + 1, 1);
	for (int i = 1; i <= m; ++i) {
		p2[i] = p2[i - 1] * 2;
		invp2[i] = 1 / p2[i];
	}
	for (int i = 1; i <= n; ++i) {
		auto ndp = dp;
		Mint cur = 0;
		for (int c = 1; c <= m; ++c) {
			ndp[c] = cur * p2[c - 1] + dp[c] * (c + 1);
			cur += dp[c] * c * invp2[c];
		}
		swap(dp, ndp);
	}
	Mint ans = dp[m];
	printf("%d\n", ans.val);
}


Measured memory_bytes: 3864
#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(){
	int n;
	cin >> n;
	
	set<int> s;
	REP(i,n){
		int a;
		cin >> a;
		if(s.find(a)==s.end()){
			s.insert(a);
		}else{
			s.erase(a);
		}
	}
	
	cout << s.size() << endl;
	
	return 0;
}

Measured memory_bytes: 8112
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
inline int tp(int t)
{
	if(n>=t) return t/10*9;
	if(n<t/10) return 0;
	return n-t/10+1;
}
int main()
{
	scanf("%d",&n);
	printf("%d",tp(10)+tp(1000)+tp(100000));
}

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

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int acount=0, bcount=0, ccount=0;
    int min_pizza;
    min_pizza = min(x, y);
    if ((a+b)*min_pizza > c*min_pizza*2) {
        ccount += (min_pizza*2);
    } else {
        acount += min_pizza;
        bcount += min_pizza;
    }
    if (max(x, y) == x) {
        int rest_pizza;
        rest_pizza = max(x, y) - min(x, y);
        if (a > c*2) {
            ccount += rest_pizza*2;
        } else {
            acount += rest_pizza;
        }
    } else {
        int rest_pizza;
        rest_pizza = max(x, y) - min(x, y);
        if (b > c*2) {
            ccount += rest_pizza*2;
        } else {
            bcount += rest_pizza;
        }
    }
    int total;
    total = acount*a+bcount*b+ccount*c;
    cout << total << endl;


    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>/*
#include <unordered_map>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <iterator>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <complex>
#include <cassert>
#include <random>
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <deque>
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <ctime>
#include <list>
#include <map>
#include <set>
//*/

//#define int long long
#define uns unsigned
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl '\n'
using namespace std;

template<class T> ostream &operator<<(ostream &os, const pair<T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const pair<const T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const array<T,3> &p){
	return os<<"("<<p[0]<<","<<p[1]<<","<<p[2]<<")";}
template<class T> ostream &operator<<(ostream &os, const vector<T> &p){
	for(auto x: p) os<<x<<' '; return os;}
#define dbug(x) cerr<<">>>> "<<#x<<" = "<<x<<endl
#define _ <<", "<<
#define FOR(X,L,R) for(int X=L;X<R;X++)
#define FI(I,X) for(auto I=(X).begin();I!=(X).end();I++)
#define print(X) {cerr<<"{ ";FI(I,X)cerr<<*I<<' ';cerr<<"}"<<endl;}
#define mset(V,X) memset(V,X,sizeof(V))
#define all(X) (X).begin(),(X).end()
#define upperb(V,X) (int)(upper_bound(all(V),(X))-V.begin())
#define lowerb(V,X) (int)(lower_bound(all(V),(X))-V.begin())

const double EPS = 1e-9, PI = acos(-1);
const ll LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9+7;
const int INF = 0x3f3f3f3f, SZ = 2e5+20;

int n,c;
int w[110],v[110],dp[100010];

int32_t main(){
	ios::sync_with_stdio(false);cin.tie(0);
	
	mset(dp,INF);
	cin>>n>>c;
	FOR(i,0,n) cin>>w[i]>>v[i];
	int total = 0;
	FOR(i,0,n) total += v[i];
	FOR(i,0,n){
		for(int j=total-v[i]; j>=0; j--)
			dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
		dp[v[i]] = min(dp[v[i]],w[i]);
	}
	for(int i=total; i>=0; i--) if(dp[i] <= c) return cout<<i<<endl, 0;

	return 0;
}

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

int main() {
	int N;
 	cin >> N;
  
    if (N / 100 - 7 == 0) {
      cout << "Yes" << endl;
    }
    
  	else if (N / 10 - N / 100 * 10 - 7 == 0) {
      cout << "Yes" << endl;
    }
  
  	else if (N - N / 10 * 10 - 7 == 0) {
      cout << "Yes" << endl;
    }
            
    else {
      cout << "No" << endl;
    }
      
}

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

int main(){
	int a,b,c,five,seven;
	cin>>a>>b>>c;
	five=(a==5)+(b==5)+(c==5);
	seven=(a==7)+(b==7)+(c==7);
	if(five==2&&seven==1)cout<<"YES";
	else cout<<"NO"; 
	return 0;
}


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

typedef long long ll;
using namespace std;

#define REP(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define sum(v) accumulate(ALL(v),0)

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

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

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

int testDevide(){
    int n = 1;
    rep(i,12){
        cout << i << ":" << n%13 << endl;
        n*=10;
    }
}

ll dp[100005][13];
char s[100005];
static const ll MOD = 1000000007;

int solve(){
    cin >> s;
    ll n = strlen(s);
    dp[0][0]=1;
    rep(i,n){
        dbg(i);
        if(s[i]=='?'){
            rep(j,10){
                rep(k,13){
                    dp[i+1][(10*k+j)%13] += dp[i][k];
                }
            }
        }else{
            rep(l,13){
                int c = s[i]-'0';
                dp[i+1][(10*l+c)%13] += dp[i][l];
            }
        }
        rep(j,13){
            dp[i+1][j] %= MOD;
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}

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

Measured memory_bytes: 10496
N=int(input())
p=list(map(int,input().split(" ")))
i=0
c=0
while i<N:
    if p[i]==i+1:
        if i<N-1 and p[i+1]==i+2:
            c+=1
            i+=1
        else:
            c+=1
    i+=1

print(c)

Measured memory_bytes: 14008
#include <stdio.h>
#include <math.h>
int n, count = 0;
double rad = M_PI/3;
void draw(double x1, double y1, double x5, double y5, int count);
int main(){
  double x1 = 0.0, x2 = 100.0, x5, y5;
  scanf("%d", &n);
  printf("%f %f\n", x1, x1);
  if(n == 0){
    printf("%f %f\n", x2, x1);
  }
  else draw(x1, x1, x2, x1, count);
  return 0; }
void draw(double x1, double y1, double x5, double y5, int count){
  double x2, y2, x3, y3, x4, y4;
  x2 = (2*x1+x5)/3.0;
  y2 = (2*y1+y5)/3.0;
  x4 = (x1+2*x5)/3.0;
  y4 = (y1+2*y5)/3.0;
  x3 = x2+(x4-x2)*cos(rad)-(y4-y2)*sin(rad);
  y3 = y2+(x4-x2)*sin(rad)+(y4-y2)*cos(rad);
  count++;
  if(count < n){
    draw(x1, y1, x2, y2, count);
    draw(x2, y2, x3, y3, count);
    draw(x3, y3, x4, y4, count);
    draw(x4, y4, x5, y5, count);
  } else{
    printf("%f %f\n", x2, y2);
    printf("%f %f\n", x3, y3);
    printf("%f %f\n", x4, y4);
    printf("%f %f\n", x5, y5);
  } }


Measured memory_bytes: 2104
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

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()));
        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)*}
    };
}

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

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
    }
    for i in 1..10 {
        if n % i == 0 && n / i < 10 {
            return println!("Yes")
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;

    bool res = false;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i + 1]) {
            res = true;
        }
    }

    if (res) {
        cout << "Bad";
    } else {
        cout << "Good";
    }
}


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

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

	for(int n, q; cin >> n >> q, n;) {
		vector<int> num(100, 0);
		for(int i = 0; i < n; ++i) {
			int m;
			cin >> m;

			for(int j = 0; j < m; ++j) {
				int date;
				cin >> date;
				++num[date];
			}
		}

		int ans = 0, mx = q - 1;
		for(int i = 1; i < 100; ++i) {
			if(num[i] > mx) {
				ans = i;
				mx = num[i];
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1204
s = input()

c=0
ok = True
if s[0]!='A':
    ok = False
else:
    for i in range(len(s)):
        if s[i]=='C' and i in range(2,len(s)-1):
            if c==0:
                c=i
            else:
                ok = False
    if c==0:
        ok=False
    else:
        s = s.replace('A','').replace('C','')
        if s!=s.lower():
            ok=False
            
if ok:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    
    int N;
    cin >> N;
    vector<pair<ll,ll>> LR(N);
    ll mx = -inf;
    ll mn = inf;
    rep(i,N){
        cin >> LR[i].first >> LR[i].second;
        LR[i].first--;
        mx = max(mx,LR[i].first);
        mn = min(mn,LR[i].second);
    }
    sort(ALL(LR));
    ll ans = 0;
    for(auto z:LR){
        ans = max(ans,max(0LL,mn - mx) + z.second - z.first);
    }
    vector<pair<ll,ll>>t;
    rep(i,N){
        ll a = max(0LL,mn - LR[i].first);
        ll b = max(0LL,LR[i].second - mx);
        t.push_back({b,-a});
    }
    sort(ALL(t));
    ll w = inf;
    rep(i,N){
        auto z = t[i];
        z.second = -z.second;
        if(i){
            ans = max(ans,w + z.first);
        }
        w = min(w,z.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4084
import math
n = int(input())

def is_prime(x):
    sqrt_x = int(math.sqrt(x))
    for i in range(2, sqrt_x + 1):
        if x % i == 0:
            return False
    return True

iter = 0
ans = []
for i in range(2, 55556):
    if is_prime(i) and i % 5 == 1:
        ans.append(i)
        iter += 1
        
    if iter == n:
        break

print(" ".join(map(str, ans)))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

int d[100001];

int main(){
  int N,A,B,ans;
  cin>>N>>A>>B;
  ans=min(A*N,B);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=305,mod=998244353;
int f[N][N][N<<1],g[N][N<<1],h[N][N<<1];
int a[N],b[N],n,m=1,K;
char s[N];

void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}

int main(){
	scanf("%s",s+1),read(K);
	n=strlen(s+1),K=min(K,n);
	for(int i=1;i<=n+1;i++,m++){
		for(;i<=n&&s[i]!='0';i++,a[m]++);
		b[m]=b[m-1]+a[m];
	}
	m--;
	f[0][0][0]=1;
	rep(i,1,m){
		memset(g,0,sizeof g);
		memset(h,0,sizeof h);
		rep(j,b[i-1],b[m]){
			rep(k,0,K*2){
				if(f[i-1][j][k]){
					if(j+a[i]<=b[m]){
						add(g[j+a[i]][k],f[i-1][j][k]);
					}
					if(a[i]){
						int t=max(0,j+a[i]-1-b[m]);
						add(h[j+a[i]-1-t][k+1+t],f[i-1][j][k]);
						if(j) add(h[j-1][k+a[i]+1],mod-f[i-1][j][k]);
					}
				}
			}
		}
		rep(j,b[i-1],b[m]-1){
			rep(k,0,K*2){
				add(g[j+1][k+1],g[j][k]);
			}
		}
		per(j,b[m],b[i-1]+1){
			rep(k,0,K*2){
				add(h[j-1][k+1],h[j][k]);
			}
		}
		rep(j,b[i],b[m]){
			rep(k,0,K*2){
				add(f[i][j][k],g[j][k]);
				add(f[i][j][k],h[j][k]);
			}
		}
	}
	int ans=0;
	rep(i,0,K*2){
		add(ans,f[m][b[m]][i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 58288
def getlist():
	return list(map(int, input().split()))

INF = float("inf")
N, Ma, Mb = getlist()
L = [[INF] * 401 for i in range(401)]
L[0][0] = 0

#処理
for i in range(N):
	a, b, c = getlist()
	for j in range(401):
		for k in range(401):
			if L[400 - j][400 - k] != INF:
				L[400 - j + b][400 - k + a] = min(L[400 - j][400 - k] + c, L[400 - j + b][400 - k + a])


#最小値
ans = INF
x = Ma
y = Mb
while y <= 400 and x <= 400:
	ans = min(ans, L[y][x])
	x += Ma
	y += Mb

if ans == INF:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 47196
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Integer
getInt = (\a -> read a :: Integer) <$> getLine

getIntArray :: IO [Integer]
getIntArray = ((map (\a -> read a :: Integer)) . words) <$> getLine

getStrArray :: Integer -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

canEat :: [Integer] -> String
canEat [x, a, b]
    | b - a <= 0 = "delicious"
    | b - a <= x = "safe"
    | otherwise = "dangerous"

main = do
    putStrLn =<< (canEat <$> getIntArray)


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

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  if (a >= k) 
    cout << a - k << " " << b << endl;
  else if (k < a + b)
    cout << 0 << " " << b - k + a << endl;
  else
    cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10, MAXN = 4e6 + 1, mod = 1e9 + 7;
int fc[MAXN + 5], ifc[MAXN + 5], n, k, dp[N][N];
int power(int a, int b) {
	if (!b)
		return 1;
	int rtr = power(a, b / 2);
	if (b % 2)
		return 1ll * rtr * rtr % mod * a % mod;
	return 1ll * rtr * rtr % mod;
}
void Pre() {
	fc[0] = ifc[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		fc[i] = 1ll * fc[i - 1] * i % mod;
		ifc[i] = power(fc[i], mod - 2);
	}
}
int ch(int x, int y) {
	return 1ll * fc[y] * ifc[x] % mod * ifc[y - x] % mod;
}
int main() {
	Pre();
	cin >> n >> k;
	if (k == 1) {
		cout << 1;
		return 0;
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
//			cout << "i = " << i << " j = " << j << endl;
			if (j > i)
				continue;
			if (i)
				dp[i][j] = dp[i - 1][j];
			if (j) {
//				cout << " : " << k - 2 << ", " << n * k - (j - 1) * (k - 1) - i << endl;
				dp[i][j] = (dp[i][j] + 1ll * dp[i][j - 1] * ch(k - 2, n * k - (j - 1) * (k - 1) - i - 1) % mod) % mod;
			}
//			cout << dp[i][j] << endl;
		}
	}
	cout << 1ll * dp[n][n] * fc[n] % mod;
	return 0;
}	


Measured memory_bytes: 46464
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long ;
int main()
{
    int n,ans=0,now=0;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n-1){
        if(a[i]>=a[i+1]) now++;
        else now=0;
        ans=max(ans,now);
    }
    cout<<ans;
}

Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    ll ans=(N/(A+B))*(A)+(N%(A+B)>A?A:N%(A+B));
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n,m,x ;
    cin >> n >> m >> x ;
    int l=0,r=0 ;
    for(int i=0;i<m;i++){
        int a ; cin >> a ;
        if(a<x) l++ ;
        else r++ ;
    }
    cout << min(l,r) << endl ;
}


Measured memory_bytes: 256
A, B = (int(x) for x in input().split())

if A > B:
    big = A
    small = B
elif B > A:
    big = B
    small = A
else:
    big = A
    small = B

if big - small >= 1:
    ans = big*2-1
    print(ans)
else:
    ans = big*2
    print(ans)


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


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
using namespace std;
typedef pair<int,int> ii;
int r,c,n; vector<ii> v[4];
bool check(int x,int y) {
	if (x==0||x==r||y==0||y==c) return true;
	return false;
}
void push(int x,int y,int val) {
	if (y==0) v[0].pb(ii(x,val));
	else if (x==r) v[1].pb(ii(y,val));
	else if (y==c) v[2].pb(ii(x,val));
	else if (!x) v[3].pb(ii(y,val));
}
bool cmp1(ii &a,ii &b) {return a.first<b.first;}
bool cmp2(ii &a,ii &b) {return a.first>b.first;}
signed main() {
	//freopen("233220.inp","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>r>>c>>n;
	/*
	Only points on the edge of the rectangle will be considered.
	Push them in vectors and start sorting them.
	Then use a stack to push and pop out easily
	Print out if the stack is empty or not.
	*/
	fw (i,0,n) {
		int x1,x2,y1,y2;
		cin>>x1>>y1>>x2>>y2;
		if (check(x1,y1)&&check(x2,y2)) {push(x1,y1,i); push(x2,y2,i);}
	}
	fw (i,0,2) sort(v[i].begin(),v[i].end(),cmp1);
	fw (i,2,4) sort(v[i].begin(),v[i].end(),cmp2);
	stack<int> s;
	fw (i,0,4) {
		fw (j,0,v[i].size()) {
			if (s.empty()) {s.push(v[i][j].second); continue;}
			if (s.top()==v[i][j].second) s.pop(); else s.push(v[i][j].second);
		}
	}
	if (!s.empty()) cout<<"NO";
	else cout<<"YES";
}

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

namespace ITP1_4_C
{
    class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                //2つの整数a,bと1つの演算子opを読み込んで、a op bを計算する。
                //opは+,-,*,/のみ。割り切れない場合は小数点以下を切り捨てる。
                //opが?の時、入力を終了し結果は出力しない。

                string[] s = Console.ReadLine().Split(' ');
                int a = int.Parse(s[0]);
                int b = int.Parse(s[2]);
                string op = s[1];

                if (op == "+")
                {
                    Console.WriteLine(a + b);
                }

                else if (op == "-")
                {
                    Console.WriteLine(a - b);
                }

                else if (op == "*")
                {
                    Console.WriteLine(a * b);
                }

                else if (op == "/")
                {
                    Console.WriteLine(a / b);
                }

                else
                {
                    break;
                }

                //Console.ReadKey();
            }
        }
    }
}



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

int main(int argc, char *argv[]){
  int i;
  int dim;
  int *data;
  //get data
  scanf("%d", &dim);
  data=(int *)malloc(sizeof(int)*dim);
  for(i=0; i<dim; i++){
    scanf("%d", &data[i]);
  }
  //reverse
  for(i=dim-1; i>0; i--){
    printf("%d ", data[i]);
  }
  printf("%d\n", data[i]);
  return(0);
}


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

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

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

    if(a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}

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

int main(){
int N = 0;
cin >> N;

vector<int> A(N);
vector<int> B(N);
vector<int> C(N-1);
  
for (int i = 0; i < N; i++ ){
 cin >> A.at(i); 
}
for (int i = 0; i < N; i++ ){
 cin >> B.at(i); 
}    
for (int i = 0; i < N-1; i++ ){
 cin >> C.at(i); 
}
 
int ans = 0;
for (int i = 0; i < N; i++ ){
 ans += B.at(i); 
}

for (int i = 0; i < N-1; i++){
  if (A.at(i+1) == A.at(i)+1){
    ans += C.at(A.at(i)-1); 
  }
}
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
#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 SORT(c) sort(ALL(x))
#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 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);
}

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1)*a%MOD;
	}
}

signed main(){
	int n; cin>>n;
	VI a(n); rep(i,n) cin>>a[i]; sort(ALL(a));
	int cnt = 0;
	if(n%2){
		if(a[0]!=0) return cout<<0<<endl,0;
		for(int i=1; i<n; i+=2){
			if(a[i]!=i+1||a[i+1]!=i+1) return cout<<0<<endl,0;
			cnt++;
		}
	}else{
		for(int i=0; i<n; i+=2){
			if(a[i]!=i+1||a[i+1]!=i+1) return cout<<0<<endl,0;
			cnt++;
		}
	}
	cout << mpow(2,cnt) << endl;

	return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    sort(A.begin(), A.end(), greater<int64_t>());

    int64_t ans = 0;
    int64_t cnt = N - 1;

    for (int64_t i = 0; i < N; i++) {
        if (cnt == 0) {
            break;
        }
        if (i == 0) {
            ans += A[i];
            cnt--;
        } else {
            if (cnt == 1) {
                ans += A[i];
                break;
            } else {
                ans += 2 * A[i];
                cnt -= 2;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4836
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,_N=N;I<_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  RL(line);

  int minc = 100;
  for(char c='a';c<='z';c++){
    int maxdist=0;
    int i0 = 0;
    for(int i=0;i<line.size();i++){
      if(line[i]==c){
        maxdist=std::max(maxdist,i-i0);
        i0=i+1;
      }
    }
    maxdist=std::max(maxdist,(int)line.size()-i0);
    minc=std::min(minc,maxdist);
  }
  P(minc)
  return 0;
}

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

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

void bubbleSort(int *data, int size) {
	int count = 0; bool flag = true;
	while (flag) {
		flag = false;
		for (int i = size - 1; i > 0; i--)
			if (data[i] < data[i - 1]) {
				swap(data[i], data[i - 1]); flag = true; count++;
			}
	}
	rep(i, size) {
		if (i != 0) cout << " " << flush;
		cout << data[i] << flush;
	}
	cout << endl << count << endl;
	return;
}

int main() {
	int n; cin >> n; int arr[n];
	rep(i, n) cin >> arr[i];
	bubbleSort(arr, n);
	return 0;
}


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


int pow(int x, int n) {
	int ans = 1;
	for (int k = 0; k < n; k++) {
		ans *= x;
	}
	return ans;
}

int main() {
	int N, M, X;
	int A[12][12];
	int C[12];
	cin >> N >> M >> X;
	for (int n = 0; n < N; n++) {
		cin >> C[n];
		for (int m = 0; m < M; m++) {
			cin >> A[n][m];
		}
	}

	for (int m = 0; m < M; m++) {
		int sum = 0;
		for (int n = 0; n < N; n++) {
			sum += A[n][m];
		}
		if (sum < X) {
			cout << "-1" << endl;
			return 0;
		}
	}
	bool is_brought[12];
	int max = pow(2, N);
	int ans = 100000 * 12;
	for (int k = 1; k <= max; k++) {
		int cost = 0;
		vector<int> sumA(M);
		for (int n = 0; n < N; n++) {

			if (((k >> n) & 1)== 1) {
				cost += C[n];
				for (int m = 0; m < M; m++) {
					sumA[m] += A[n][m];
				}
			}
		}

		// 理解度X以上
		bool can_understand = true;
		for (int m = 0; m < M; m++) {
			if (sumA[m] < X) {
				can_understand = false;
			}
		}
		if (can_understand == true && cost < ans) {
			ans = cost;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a.at(i);
  sort(all(a));
  vb out(1000001,false);
  int ans = 0;
  rep(i,n){
    int b = a.at(i);
    if(out.at(b)) continue;
    ans++;
    if(i < n-1){
      if(b == a.at(i+1)) {
        out.at(b) = true;
        ans--;
      }
    }
    for(int j=1;b*j<=1000000;j++){
      out.at(b*j) = true;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4756
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String a = scan.next();
			String b = scan.next();
			if(a.equals("0") && b.equals("0")){
				break;
			}
			int hit = 0;
			int blow = 0;
			for(int i = 0;i < a.length();i++){
				for(int j = 0;j < b.length();j++){
					if(a.charAt(i) == b.charAt(j)){
						if(i == j){
							hit += 1;
						}else{
							blow += 1;
						}
					}
				}
			}
			System.out.println(hit + " " + blow);
		}
	}
}

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

void main_()
{
    array<int64_t, 3> as;
    cin >> as[0] >> as[1] >> as[2];

    if (any_of(begin(as), end(as),
            [](auto a) { return (a % 2) == 0; })) {
        cout << 0 << endl;
    } else {
        auto ans = min({ as[0] * as[1], as[0] * as[2], as[1] * as[2] });
        cout << ans << endl;
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
def knapsack2(N,W,weight,value,WW):
  #初期化
  inf=float("inf")
  dp=[[-inf for i in range(WW)] for j in range(N+1)]
  for i in range(WW):
      dp[0][i]=0
  maxval = 0
  #DP
  for i in range(N):
    for w in range(WW):
      if weight[i]<=w:
        if w-weight[i]>=W: #時間切れ
          dp[i+1][w]=dp[i][w]
        else: #注文可能
          dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
      else: #NG
        dp[i+1][w]=dp[i][w]
    maxval = max([maxval, max(dp[i+1])])
  return maxval
 
N, T = map(int,input().split())
WW = T+3000
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
ab =  sorted(ab,key=lambda x:x[0])
weight = [elem[0] for elem in ab]
value = [elem[1] for elem in ab]
res = knapsack2(N,T,weight,value,WW)
print(res)

Measured memory_bytes: 361496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    string s, t="";
    cin >> s;
    t.push_back(s[0]);
    for(int i=1;i<s.size();i++){
        if(t.back() == 'B' && s[i]=='C'){
            t.pop_back();
            t.push_back('D');
        }
        else{
            t.push_back(s[i]);
        }
    }
    reverse(ALL(t));
    ll ans = 0, cntd = 0;
    for(int i=0;i<t.size();i++){
        if(t[i] == 'A') ans += cntd;
        else if(t[i] == 'D') cntd++;
        else cntd = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

typedef long long int ll;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int modi = 1e9 + 7;

ll gcd(ll a,ll b){ return b?gcd(b,a%b):a ;}

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

void solve(){
	int n;
	cin >> n;
	ll a[n];
	for(int i =0;i<n;i++)
		cin >> a[i];
	// reduce all to its smaller form
	map<int,int> lcm_factors;
	for(int i =0;i<n;i++){
		ll val = a[i];
		for(int j = 2;j*j<=val;j++){
			if(val%j == 0){
				int cnt = 0;
				while(val%j==0){
					cnt++;
					val/=j;
				}
				if(lcm_factors.count(j))
					lcm_factors[j] = max(lcm_factors[j],cnt);
				else
					lcm_factors[j] = cnt;
			}
		}
		if(val>1){
			if(lcm_factors.count(val))
			lcm_factors[val] = max(lcm_factors[val],1);
 			else
 				lcm_factors[val] = 1;
 		}
	}
	ll lcm = 1;
	for(auto e:lcm_factors){
		lcm = lcm*binpow(e.first,e.second)%modi;
	}
	// for(auto e:lcm_factors){
	// 	cout << e.first <<  " " << e.second << endl;
	// }
	ll ans = 0;
	for(int i =0;i<n;i++){
		ans = (ans+(lcm*binpow(a[i],modi-2))%modi)%modi;
	}
	// ans = ans*lcm%modi;
	cout << ans << endl;
}

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

	// int t;cin >> t;while(t--)
		solve();
}


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

int main() {
  int n, m, X, Y;
  cin>>n>>m>>X>>Y;
  int x[n], y[m];
  for (int i=0; i<n; i++) cin>>x[i];
  for (int i=0; i<m; i++) cin>>y[i];
  sort(x, x + n);
  sort(y, y + m);
  if (x[n-1] < y[0] && x[n-1] > X && y[0] <= Y) {
    cout<<"No War"<<endl;
  } else {
    cout<<"War"<<endl;
  }
}

Measured memory_bytes: 256