akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;

struct Graph{
  Graph(int n):d(n,vector<int>(n,INF)),N(n){
    for(int i=0;i<n;++i)d[i][i]=0;
  }
  vector<vector<int>>d;
  int N;
  void add_edge(int a,int b,int c){
    d[a][b]=c;
  }
  void warshallFloyd(){
    for(int k=0;k<N;++k)
      for(int i=0;i<N;++i)
        for(int j=0;j<N;++j)
          d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  }
};
int main(){
    int H,W;
    cin>>H>>W;
    Graph G(10);
    for(int i=0;i<10;++i)
        for(int j=0;j<10;++j){
            int c;
            cin>>c;
            G.add_edge(i,j,c);
        }
    G.warshallFloyd();
    int x=0;
    for(int i=0;i<H;++i)
        for(int j=0;j<W;++j){
            int a;
            cin>>a;
            if(a>-1) x+=G.d[a][1];
        }
    cout<<x<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int n; cin>>n;
	if(n<1000) cout<<"ABC";
	else cout<<"ABD";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int a, b; cin >> a >> b;
	if (a <= 5) cout << 0 << endl;
	else if (a <= 12) cout << b / 2 << endl;
	else cout << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN],b[MAXN],c[MAXN],deq[MAXN];
vector<int> v;
void solve()
{
	int s=0,t=0;
	for(int i=0;i<n;i++)
	{
		while(s<t&&a[deq[t-1]]<=a[i]) t--;
		deq[t++]=i;
		if(i-k+1>=0)
		{
			b[i-k+1]=a[deq[s]];
			if(deq[s]==i-k+1)
			{
				s++;
			}
		}
	}
}
void solve2()
{
	int s=0,t=0;
	for(int i=0;i<n;i++)
	{
		while(s<t&&a[deq[t-1]]>=a[i]) t--;
		deq[t++]=i;
		if(i-k+1>=0)
		{
			c[i-k+1]=a[deq[s]];
			if(deq[s]==i-k+1)
			{
				s++;
			}
		}
	}
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    solve(); solve2();
    int ans=0,cnt=0;
    v.clear();
    for(int i=0;i<n;i++)
    {
        if(v.size()&&v.back()>a[i]) v.clear();
        v.push_back(a[i]);
        if(i>=k-1)
        {
            if(v.size()>=k) {cnt++; ans++; continue;}
            if(i==k-1) {ans++; continue;}
            if(a[i]!=b[i-k+1]||a[i-k]!=c[i-k]) ans++;
            //printf("%d %d %d %d %d %d\n",i,a[i],b[i-k+1],a[i-k],c[i-k],ans);
        }
    }
    if(cnt) ans=ans-cnt+1;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4472
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    h=list(map(int,readline().split()))

    count=0
    while 1:
        first=True
        for i in range(N):
            if first and h[i]>=1:
                first=False
                h[i]-=1
            elif first and h[i]==0:
                pass
            elif first is False and h[i]>=1:
                h[i]-=1
            elif first is False and h[i]==0:
                break
        if first:
            break
        else:
            count+=1
    print(count)

if __name__=="__main__":
    main()

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

int dp[1000005];

const long long MOD = 1e9+7;

int main(){
    int N, H, D;
    scanf("%d%d%d", &N, &H, &D);

    long long retainWays = 0;
    long long fact = 1;
    for(int i = 1; i <= N; i ++){
        fact = fact*i%MOD;
        retainWays += fact;
    }
    retainWays %= MOD;

    //printf("retainWays=%lld\n", retainWays);

    dp[0] = fact;
    int slidingWindowSum = dp[0];
    for(int i = 1; i < D; i ++){
        dp[i] = slidingWindowSum*retainWays%MOD;

        slidingWindowSum += dp[i];

        if(slidingWindowSum >= MOD){slidingWindowSum -= MOD;}

        //printf("dp[%d]=%lld\n", i, dp[i]);
    }
  
  	for(int i = D; i < H; i ++){
        dp[i] = slidingWindowSum*retainWays%MOD;

        slidingWindowSum += dp[i]-dp[i-D];

        if(slidingWindowSum >= MOD){slidingWindowSum -= MOD;}
        else if(slidingWindowSum < 0){slidingWindowSum += MOD;}

        //printf("dp[%d]=%lld\n", i, dp[i]);
    }

    printf("%d", slidingWindowSum);
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    for(int i= 0; i < N; i++){
        char S;
        cin >> S;
        if (S=='Y'){
            std::cout << "Four" << std::endl;
            break;
        }
        else if(i==N-1)
        {std::cout << "Three" << std::endl;}
    }
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    vector<vector<ll>>dp(s.size()+1,vector<ll>(2,0));
    dp[0][0]=1;//flag0でLと同じ
    for(int i=1;i<=s.size();i++){
        for(int j=0;j<2;j++){
            if(j==0){
                if(s[i-1]=='1'){
                    dp[i][j]+=dp[i-1][j]*2;//10or01
                }
                else{
                    dp[i][j] += dp[i - 1][j];//00
                }
                dp[i][j] %= MOD;
            }
            else{
                if (s[i - 1] == '1')
                {
                    dp[i][j] += dp[i - 1][j] * 3; //10or01or00
                    dp[i][j] += dp[i - 1][0];//00
                }
                else
                {
                    dp[i][j] += dp[i - 1][j] * 3; //10or01or00
                }
                dp[i][j]%=MOD;
            }
        }
    }
    cout << (dp[s.size()][0]+dp[s.size()][1])%MOD<< "\n";
}


Measured memory_bytes: 5840
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	var ans int
	for i := 1; i*i <= N; i++ {
		if N%i != 0 {
			continue
		}

		ans += calc(N, i)
		ans += calc(N, N/i)
	}

	fmt.Println(ans)
}

func calc(N, m int) int {
	m--
	if m < 1 {
		return 0
	} else if N/m == N%m {
		return m
	}

	return 0
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(ans < abs(A[i]-A[j])){
                ans = abs(A[i]-A[j]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main () {
  int W, w, Q, id, f, i, j, k, l;
  char r;
  while(cin >> W >> Q, W != 0 || Q != 0) {
    int MAP[100] = {};
    for(k = 0; k < Q; k++) {
    //   for(l = 0; l < W; l++) {
    //   	cout << MAP[l];
    //   }
    //   cout << endl;
      cin >> r;
      if(r == 's') {
	cin >> id >> w;
	id++;
	for(i = 0; i < W; i++) {
	  f = 0;
	  for(j = i; j < w + i && j < W; j++) {
	    if(MAP[j] != 0) {
	      f = 1;
	      //  i = j;
	      break;
	    }
	  }
	  if(f == 0) break;
	}
	if(f == 0 && j - i == w )  {
	  cout << i << endl;
	  for(j = i; j < w + i; j++) {
	    MAP[j] = id;
	  }
	}
	else cout << "impossible" << endl;
      }
      else if(r == 'w') {
	cin >> id;
	id++;
	for(i = 0; i < W; i++) {
	  if(id == MAP[i]) MAP[i] = 0;
	}
      }
    }
  cout << "END" << endl;
  }
  return 0;
}

      
	  
	
    

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

using namespace std;

int main()
{
    int i,j,k,x=0,m=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='A' || s[i]=='C' || s[i]=='T' || s[i]=='G')
        {
            x++;
        }
        else
        {
            x=0;
        }
        m=max(m,x);
    }
    cout<<m<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
bool res(int n){
	string s=to_string(n);
	int i,l,r;
	REP(i,1,s.length()-1){
        l=(int)s[i]-48;
        r=(int)s[i-1]-48;
        if(abs(l-r)>1){
        	return false;
        }
	}
	return true;
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	    ll n,i,j,k,l;
	    cin>>k;
	    i=0;
	    vector<ll> v;
        v.push_back(1);v.push_back(2);v.push_back(3);v.push_back(4);
        v.push_back(5);v.push_back(6);v.push_back(7);v.push_back(8);v.push_back(9);
        while(1){
        	n=v[i];
        	if(n%10==0){
                v.push_back(n*10);
        		v.push_back(n*10+1);
        	}
        	if(n%10==1){
        		v.push_back(n*10);
        		v.push_back(n*10+1);
        		v.push_back(n*10+2);
        	}
        	if(n%10==2){
        		v.push_back(n*10+1);
        		v.push_back(n*10+2);
        		v.push_back(n*10+3);
        	}
        	if(n%10==3){
        		v.push_back(n*10+2);
        		v.push_back(n*10+3);
        		v.push_back(n*10+4);
        	}
        	if(n%10==4){
        		v.push_back(n*10+3);
        		v.push_back(n*10+4);
        		v.push_back(n*10+5);
        	}
        	if(n%10==5){
        		v.push_back(n*10+4);
        		v.push_back(n*10+5);
        		v.push_back(n*10+6);
        	}
        	if(n%10==6){
        		v.push_back(n*10+5);
        		v.push_back(n*10+6);
        		v.push_back(n*10+7);
        	}
        	if(n%10==7){
        		v.push_back(n*10+6);
        		v.push_back(n*10+7);
        		v.push_back(n*10+8);
        	}
        	if(n%10==8){
        		v.push_back(n*10+7);
        		v.push_back(n*10+8);
        		v.push_back(n*10+9);
        	}
        	if(n%10==9){
        		v.push_back(n*10+9);
                v.push_back(n*10+8);
        	}
        	i++;
        	if(v.size()>=200000){
        		break;
        	}
        }
        sort(v.begin(),v.end());
     cout<<v[k-1];
	    
	
	return 0;
}


Measured memory_bytes: 3444
import sys,bisect

from sys  import stdin,stdout

from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right

from math import gcd,ceil,floor,sqrt

from collections import Counter,defaultdict,deque,OrderedDict

from queue import Queue,PriorityQueue

from string import ascii_lowercase

sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 998244353
mod = 10**9+7

def isPrime(n):
    
    if (n <= 1) :return False
    if (n <= 3) :return True
    if (n%2 == 0 or n%3 == 0):return False
    for i in range(5,ceil(sqrt(n))+1,6):
        if (n%i==0 or n%(i+2)==0):
            return False
    return True


def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")
    
def DFS(dictionary,vertex,visited):
    visited[vertex]=True
    stack=[vertex]
    print(vertex)
    while stack:
        a=stack.pop()
        for i in dictionary[a]:
            if not visited[i]:
                print(i)
                visited[i]=True
                stack.append(i)


def BFS(dictionary, vertex,visited):
    visited[vertex]=True
    q=deque()
    q.append(vertex)
    while q:
        a=q.popleft()
        for i in dictionary[a]:
            if not visited[i]:
                visited[i]=True
                q.append(i)
                print(i)

                


def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    n=inp()
    l=li()
    ans=0
    for i in range(1,n):
        if l[i-1]>l[i]:
            v=l[i-1]-l[i]
            ans+=v
            l[i]+=v
    pr(ans)
    




for _ in range(1):
    solve()
    


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll x,y,z;
	sc(x);sc(y);sc(z);
	if(x==y)pr(z);
	else if(x==z)pr(y);
	else pr(x);	
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main(void){
    int H, W;
    cin >> H >> W;
    
    int a[500][500];
    char str[250000][20];
    int i, j, N = 0;
    
    for(i = 0; i < H; i++){
        for(j = 0; j < W; j++){
            cin >> a[i][j];
            if(j >= 1 && a[i][j - 1] % 2 == 1){
                sprintf(str[N], "%d %d %d %d", i + 1, j, i + 1, j + 1);
                a[i][j]++;
                N++;
            }
        }
    }
    
    j = W - 1;
    for(i = 1; i < H; i++){
        if(a[i - 1][j] % 2 == 1){
            sprintf(str[N], "%d %d %d %d", i, j + 1, i + 1, j + 1);
            a[i][j]++;
            N++;
        }
    }
    
    cout << N << endl;
    for(i = 0; i < N; i++){
        cout << str[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 7296
ALPHABET = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

def main():
    N = int(input())
    S = input().strip()

    ans = ""
    for s in S:
        index = ALPHABET.index(s) + N
        ans += ALPHABET[index % len(ALPHABET)]

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, _ := sc.NextInt()
	k, _ := sc.NextInt()
	a, _ := sc.NextInts(n)
	ans := solve(n, k, a)
	fmt.Println(strings.Join(Ints2Strs(ans), " "))
}

func solve(n, k int, a []int) (ans []int) {
	for i := 0; i < k; i++ {
		a2 := operate(a)
		if sliceEquals(a, a2) {
			break
		}
		a = a2
	}
	return a
}

func operate(a []int) []int {
	n := len(a)
	b := make([]int, n+1)
	for i, ai := range a {
		left, right := Max(0, i-ai), Min(i+ai+1, n)
		b[left]++
		b[right]--
	}
	a2 := make([]int, n)
	a2[0] = b[0]
	for i := 1; i < n; i++ {
		a2[i] = a2[i-1] + b[i]
	}
	return a2
}

func sliceEquals(a, b []int) bool {
	for i := range a {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

// Ints2Strs converts int slice to string slice
func Ints2Strs(slice []int) []string {
	strs := []string{}
	for _, v := range slice {
		strs = append(strs, strconv.Itoa(v))
	}
	return strs
}

// Max returns max value of inputs
func Max(a ...int) (max int) {
	for i, ai := range a {
		if i == 0 || ai > max {
			max = ai
		}
	}
	return max
}

// Min returns minimum value of inputs
func Min(a ...int) (min int) {
	for i, ai := range a {
		if i == 0 || ai < min {
			min = ai
		}
	}
	return min
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}

// NextInts reads n integers from io stream.
func (sc *Scanner) NextInts(n int) (arr []int, e error) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		v, e := sc.NextInt()
		if e != nil {
			return nil, e
		}
		arr[i] = v
	}
	return arr, nil
}


Measured memory_bytes: 21828
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
llint mod = 1000000007;


int main() {
  string s;
  cin >> s;
  llint n = s.size();
  char c[n];
  for (int i = 0; i < n; i++) {
    c[i] = s.at(i);
  }
  vector<vector<llint>> v(13, vector<llint>(n, 0));
  if (c[0] == '?') {
    for (int i = 0; i < 10;i++) {
      v[i][0] = 1;
    }
  }
  else {
    v[c[0] - '0'][0]=1;
  }
  for (int i = 1; i < n; i++) {
    if (c[i] == '?') {
      for (int j = 0; j < 13; j++) {
        for (int k = 0; k < 10; k++) {
          int p = (j * 10 + k) % 13;
          v[p][i] += v[j][i-1];
          v[p][i]%=mod;
        }
      }
    }
    else {
      for (int j = 0; j < 13; j++) {
        int p = j * 10 + (c[i] - '0');
        p%=13;
        v[p][i] += v[j][i-1];
        v[p][i] %= mod;
      }
    }
  }
  printf("%lld", v[5][n-1]);
}

Measured memory_bytes: 11520
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    int n,m,c,a,sum=0,ans=0;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i=0; i<m; i++)cin >> b[i];
    for(int i=0; i<n; i++){
        sum=0;
        for(int j=0; j<m; j++){
            cin >> a;
            sum+=a*b[j];
        }
        if(sum+c>0)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s,t;
  std::cin >> s>>t;
  int ans=0;
  if(s[0]==t[0])ans++;
  if(s[1]==t[1])ans++;
  if(s[2]==t[2])ans++;
  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
	ios_base::sync_with_stdio(false); 
	int n,x,t;
  	cin>>n>>x>>t;
  	if(n%x==0)
    {
      cout<<(n/x)*t;
    }
  	else
    {
      cout<<((n/x)+1)*t;
    }
	
	return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int T = scanner.nextInt();
		int X = scanner.nextInt();
		scanner.close();
		double ans = (double) T / (double) X;
		System.out.println(String.format("%.10f", ans));
	}
}

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

int main(){
	int n,t,custo,tempo,min=1001;
	
	cin>>n>>t;

	while(n--){
		cin>>custo>>tempo;
		if(tempo<=t){
			if(min>custo){
				min=custo;
			}
		}
	}

	if(min>1000)
		cout<<"TLE"<<endl;
	else
		cout<<min<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int a,b,c,d;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
       printf("%d\n",min(b,d)-max(a,c)>0?min(b,d)-max(a,c):0);


    return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout

INF = float('inf')
n, k = map(int, stdin.readline().split())
vl = list(map(int, stdin.readline().split()))
dp = [INF for i in range(n)]
dp[0] = 0

for i in range(n - 1):
    for j in range(1, k + 1):
        if i + j == n:
            break
        
        dp[i + j] = min(dp[i + j], dp[i] + abs(vl[i + j] - vl[i]))

stdout.write(str(dp[-1]))

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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		//assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};
map<ll, ll>prime_factor(ll n) {
	map<ll, ll>res;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			res[i]++; n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	combination com(300010);
	ll n, m; cin >> n >> m;
	map<ll, ll>mp = prime_factor(m);
	mint ans = 1;
	for (auto p : mp) {
		ans *= com(p.second + n - 1, p.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7860
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

string S;

signed main(){
    cin >> S;
    rep(i, S.size()){
        if(S[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int max = Math.max(A, Math.max(B, C));
    int diff = 3 * max - A - B - C;
    System.out.println(diff % 2 == 0 ? diff / 2 : (diff + 3) / 2);
  }

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

Vll fac(200005, -1);

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

ll modfactorial(ll n, ll mod)
{
  if (fac[n] != -1) return fac[n];
  REP(i, n+1)
  {
    if (fac[i] != -1) continue;
    if (i == 0) fac[i] = 1;
    else fac[i] = i * fac[i-1] % mod;
  }
  return fac[n];
}

ll modnCk(ll n, ll k, ll mod)
{
  ll res = modfactorial(n, mod);
  res = res * modpow(modfactorial(k, mod), mod-2, mod) % mod;
  res = res * modpow(modfactorial(n-k, mod), mod-2, mod) % mod;
  return res;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  ll ans = 0;
  ans += modnCk(B+H-A-1, B, MOD) * modnCk(A+W-B-1, A, MOD);
  ans %= MOD;
  if (B == W-1)
  {
    cout << ans << endl;
    return 0;
  }
  REP(i, H-A-1)
  {
    ans += modnCk(i+B, i, MOD) * modnCk(W-B-2+H-i-1, W-B-2, MOD);
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
using System;

class Program
{
	static void Main()
	{
		int x = int.Parse(Console.ReadLine());
		string s = null;
		
		for (int i = 0; i < x; i++)
		{
			int o = 0;
			int run = 0;
			int ten = 0;
			
			while(true)
			{
				s = Console.ReadLine();
				if (s == null) break;
				
				if (s.Equals("OUT"))
				{
					o++;
					if (o == 3) break;
				} 
				else if (s.Equals("HIT"))
				{
					run++;
					if (run == 4)
					{
						ten += 1;
						run -= 1;
					}
				}
				else if (s.Equals("HOMERUN"))
				{
					ten += 1;
					ten += run;
					run = 0;
				}
			}
			
			Console.WriteLine(ten.ToString());
		}
	}
}



Measured memory_bytes: 13740
#include <stdio.h>

int main(){
	int j,s_length = 0;
	char s[101],p[101];
	scanf("%s",s);
	scanf("%s",p);

	for(int i = 0; s[i] != '\0';i++) s_length++;

	for(int left = 0;s[left] != '\0';left++){
		for(j = 0;p[j] != '\0' && p[j] == s[(left+j)%s_length];j++);
		if(p[j] == '\0'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}





Measured memory_bytes: 2700
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: "List[int]", B: "List[int]"):
    S = sorted([(B[i],A[i]) for i in range(N)])
    current = 0
    for i in range(N):
        current += S[i][1]
        if current > S[i][0]:
            print(NO)
            exit()
    print(YES)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34140
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	maxBufsize = 1000000
)

func inputs(lines int) []string {
	var strSlice []string

	rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)

	for i := 0; i < lines; i++ {

		line := ReadLine(rdr)
		strSlice = append(strSlice, line)

	}

	return strSlice
}

// ReadLine is to read long line
func ReadLine(rdr *bufio.Reader) string {
	buf := make([]byte, 0, maxBufsize)
	for {
		l, p, e := rdr.ReadLine()

		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}

	return string(buf)
}

func modpow(a, n, mod int64) int64 {
	r := int64(1)

	for {
		if (n & 1) == 1 {
			r = (r * a) % mod
		}
		n = n >> 1
		a = (a * a) % mod
		if n <= 0 {
			break
		}
	}

	return r
}

func main() {
	lines := inputs(1)

	nk := strings.Split(lines[0], " ")
	N, _ := strconv.Atoi(nk[0])
	K, _ := strconv.Atoi(nk[1])

	cnt := make([]int64, K+1)
	MOD := int64(math.Pow(10.0, 9.0)) + 7
	for i := 1; i <= K; i++ {
		cnt[i] = modpow(int64(K/i), int64(N), MOD)
	}

	for i := K; i > 0; i-- {
		for gg := i * 2; gg <= K; gg += i {
			cnt[i] += MOD - cnt[gg]
		}

		cnt[i] = cnt[i] % MOD
	}

	var sums int64

	for i := 1; i <= K; i++ {
		sums += cnt[i] * int64(i)
	}

	ans := sums % MOD
	fmt.Println(ans)
}


Measured memory_bytes: 2660
def main():
  n, a = map(int, input().split())
  xlst = list(map(int, input().split()))

  """
  #dp[i][j][k] ... iまででj個使ってkを作る
  #dp[i][j][k] += dp[i - 1][j - 1][k - x]
  
  xlst.insert(0, 0)
  dp =  [[[0] * (50 * n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
  for i in range(n + 1):
    dp[i][0][0] = 1
  
  
  for i in range(1, n + 1):
    x = xlst[i]
    dpi = dp[i]
    dpi_1 = dp[i - 1]
    for j in range(1, n + 1):
      dpij = dpi[j]
      dpi_1j = dpi_1[j]
      dpi_1j_1 = dpi_1[j - 1]
      for k in range(1, n * 50 + 1):
        if k >= x:
          #dp[i][j][k] += dp[i - 1][j - 1][k - x] + dp[i - 1][j][k]
          dpij[k] += dpi_1j_1[k - x] + dpi_1j[k]
        else:
          #dp[i][j][k] += dp[i - 1][j][k]
          dpij[k] += dpi_1j[k]

  ans = 0
  for j in range(1, n + 1):
    ans += dp[n][j][j * a]
  
  print(ans)

  """

  dp = [[0] * (n * 50 + 1) for _ in range(n + 1)]
  dp[0][0] = 1

  for x in xlst:
    for j in range(n, 0, -1):
      dpj = dp[j]
      dpj1 = dp[j - 1]
      for k in range(x, n * 50 + 1):
        dpj[k] += dpj1[k - x]

  print(sum([dp[j][j * a] for j in range(1, n + 1)]))
main()

Measured memory_bytes: 40176
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int n, m, a[200001];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m; vector<pair<int,int>> vec;
    for(int i = 0; i < m; i++){
        int l, r; cin >> l >> r;
        vec.pb({r,l});
    }
    sort(vec.begin(),vec.end());
    int cnt =0, st = 0;
    for(auto i : vec){
        if(i.s >= st){
            cnt++;
            st = i.f;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4268
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  ll n,x,m; cin >>n >>x >>m;
  set<ll>s; vector<ll>v; bool ok=1; int cnt=0,rec;
  for(int i=0; i<n; i++){
    s.insert(x); cnt++;
    if(s.size()-cnt){rec=x; ok=0; break;}
    v.push_back(x);
    x*=x; x%=m;
  }
  ll ans=0;
  for(auto i:v) ans+=i;
  if(ok){cout <<ans; return;}
  int q=v.size();
  for(int i=0; i<q; i++) if(v[i]==rec){rec=i; break;}
  ll rem=0;
  for(int i=rec; i<q; i++) rem+=v[i];
  n-=q; ans+=n/(q-rec)*rem; n%=(q-rec); rem=0;
  for(int i=0; i<n; i++) rem+=v[i+rec];
  ans+=rem;
  cout <<ans;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  //int T; cin >>T; while(T--)
  solve();
return 0;}

Measured memory_bytes: 5980
//AtCoder Beginner Contest 074 B
#include<bits/stdc++.h>
using namespace std;
int MAXN = 110;
int main(){
  int x[MAXN];
  int N, K,ans = 0;
  cin >> N >>K;
  double j;
  j = K /2;
  for (int i = 0; i < N; i++){
    cin >> x[i];
    if (x[i] > j){
      ans += 2*(K - x[i]);
    }
    else{
      ans += 2*x[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  int a,b;cin >> a >> b;
  vector<pair<int,int>> vec(a);
  rep(i,a) {
    pair<int,int> s;
    cin >> s.first;
    s.second = i+1;
    vec[i]=s;
  }
  sort(vec.begin(),vec.end());
  int Ans = 0;
  rep(i,b) {
    Ans += vec[i].first;
  }
  cout << Ans << endl;
}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> p){
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (p[i] != i+1) cnt++;
    }
    if (cnt <= 2) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


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



void solve(long long N, std::vector<long long> A, long long Q, std::vector<long long> B, std::vector<long long> C){

    unordered_map<ll,ll> um;
    ll ans = 0;
    for(auto &&elm : A) {
        if(um.count(elm) == 0) um[elm]=1;
        else um[elm]++;
        ans += elm;
    }

    for(ll i=0; i<Q; i++) {
        if(um.count(B[i]) != 0){
            if(um[C[i]] == 0){
                um[C[i]] = um[B[i]];

            }
            else{
                um[C[i]] += um[B[i]];
            }
            ans -= (B[i] - C[i])*um[B[i]];
            um.erase(B[i]);
        }

    cout << ans << endl;
    }

    
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> B(Q);
    std::vector<long long> C(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), Q, std::move(B), std::move(C));
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

int dp[(1<<18)+2][19] , a[2][25] ;
int n ;

int f(int mask , int last)
{
    if( mask == ((1<<n)-1) ) return 0 ;
    if( dp[mask][last] != -1 ) return dp[mask][last] ;

    int idx = 0 ;
    for(int i=0 ; i<n ; i++) idx += ( (mask>>i)&1 ) ;

    int cost = 0 ;

    int res = INF , fl=(idx%2) ;

    for(int i=0 ; i<n ; i++)
    {
        if( (mask&(1<<i)) ) continue ;

        if( idx>0 )
        {
            if( a[(fl^1)][last] <= a[fl][i] ) res = min(res,cost+f((mask|(1<<i)),i) ) ;
        }
        else{
            res = min(res,cost + f((mask|(1<<i)),i) ) ;
        }
        cost++ ;
    }

    return dp[mask][last] = res ;
}

int main()
{
    scanf("%d",&n) ;

    for(int j=0 ; j<2 ; j++)
    {
        for(int i=0 ; i<n ; i++)
        {
            scanf("%d",&a[j][i]) ;
        }
    }

    for(int i=1 ; i<n ; i+=2) swap( a[0][i] , a[1][i] ) ;

    memset(dp,-1,sizeof(dp)) ;

    if( f(0,0) != INF ) printf("%d\n",f(0,0)) ;
    else printf("-1\n") ;

    return 0 ;
}


Measured memory_bytes: 19712
L=input()
INF=10**9+7
N=len(L)
ans=0
c=0
for i in range(N):
    if L[i]=="0":
        continue
    ans+=pow(2,c,INF)*pow(3,N-1-i,INF)%INF
    c+=1
ans+=pow(2,c,INF)
print(ans%INF)


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int N, M, ans=INF;
	int A[305][305];

	cin >> N >> M;
	rep(i,N) rep(j,M) cin >> A[i][j], A[i][j]--;

	bool f[305]={};
	rep(k,M){
		int cnt[305]={};
		int mx=0;
		rep(i,N) rep(j,M) if( !f[A[i][j]] ){
			cnt[A[i][j]]++;
			chmax(mx, cnt[A[i][j]]);
			break;
		}
		chmin(ans, mx);
		rep(i,M) if( cnt[i] == mx ){
			f[i] = true;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


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


int main(int argc, char const *argv[]) {
	

	string Data;
	cin >> Data;

	bool IsPossible = true;

	if (Data.find("N") != string::npos and Data.find("S") == string::npos)
		IsPossible = false;

	if (Data.find("S") != string::npos and Data.find("N") == string::npos)
		IsPossible = false;

	if (Data.find("E") != string::npos and Data.find("W") == string::npos)
		IsPossible = false;

	if (Data.find("W") != string::npos and Data.find("E") == string::npos)
		IsPossible = false;

	if (IsPossible) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1|N>=40:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break

Measured memory_bytes: 3060
k = int(input())

# 関数S(n)
def S(num):
  s = sum(map(int,list(str(num))))
  return num/s

#1~9と 〇9-> 〇99 -> 〇999 を出力
ten = 0
now = 1
# k回ループ
for _ in range(k) :
  print(now)
  # 桁が変わる時にten+=1する
  if S(now + 10**ten) > S(now + 10**(ten + 1)) :
    #print(now,S(now + 10**ten), S(now + 10**(ten + 1)))
    ten += 1
  now += 10**ten
    
    
  
  
  
  




Measured memory_bytes: 3188
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:#例　26*12 = 26^1 * 11 + 26^0 * 26に変換する
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
n = int(input())
print(num2alpha(n).lower())


Measured memory_bytes: 9112
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;


static class P
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var res = new long[n];
        for (int i = 1; i < n; i++)
        {
            res[i] = a[i - 1] - res[i - 1];
        }
        res[0] = (a.Last() - res.Last()) / 2;
        for (int i = 1; i < n; i++)
        {
            res[i] = a[i - 1] - res[i - 1];
        }
        Console.WriteLine(string.Join(" ", res.Select(x => x * 2)));
    }
}


Measured memory_bytes: 34140
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

llint n;
llint w[305];
bool dp[305][305];
llint dp2[305];

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		for(int i = 1; i <= n; i++) cin >> w[i];
		
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				dp[i][j] = false;
			}
		}
		for(int i = 1; i <= n-1; i++){
			dp[i][i+1] = (abs(w[i]-w[i+1]) <= 1);
		}
		for(int len = 4; len <= n; len += 2){
			for(int l = 1; l+len-1 <= n; l++){
				llint r = l+len-1;
				for(int k = l+1; k <= r; k++) dp[l][r] |= dp[l][k-1] && dp[k][r];
				if(abs(w[l]-w[r]) <= 1) dp[l][r] |= dp[l+1][r-1];
			}
		}
		
		for(int i = 0; i <= n; i++) dp2[i] = -inf;
		dp2[0] = 0;
		for(int i = 0; i < n; i++){
			dp2[i+1] = max(dp2[i+1], dp2[i]);
			for(int j = i+1; j <= n; j++){
				if(dp[i+1][j]) dp2[j] = max(dp2[j], dp2[i]+(j-i));
			}
		}
		cout << dp2[n] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll x=0,y=0;
    ll judge=0;
    for(ll i=0;i<n;i++){
        if(a[i]==a[i+1]&&judge==0){
            x=a[i];
            judge++;
            i++;
            continue;
        }
        if(a[i]==a[i+1]&&judge==1){
            y=a[i];
            judge++;
        }
    }
    ll ans=x*y;
    cout << ans << endl;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll a,b,c;
	cin >> a >> b >> c;
	if (a > b){
		if (c <= a && c >= b){
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else{
		if (c >= a && c <= b){
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	cin >> a;
}

Measured memory_bytes: 256
/*
				C++
				encoding: UTF-8
				Last Modified: 22/Aug/20 05:32:34 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

#define int int64_t

template < typename T > void print (const T& t) {
	cout << t << '\n';
}

template < typename T, typename U, typename... ARGS >
void print (const T& t, const U& u, const ARGS&... args) {
	cout << t << " ";
	print (u, args...);
}

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n, x, t;
	cin >> n >> x >> t;
	int ans = ceil (n / (x * 1.0)) * t;
	print (ans);
	return 0;
}

Measured memory_bytes: 3580
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	int n,i,j;cin>>n;bool v[n+1][n+1];for(i=1;i<=n;i++) for(j=1;j<=n;j++) cin>>v[i][j];
	vi d(1<<n,0);d[0]=1;for(j=1;j<(1<<n);j++){
		int x=__builtin_popcount(j);
		for(i=0;i<n;i++){
			if(v[x][i+1]&&((1<<i)&j)) d[j]=(d[j]+d[j^(1<<i)])%mod;
		}
	}cout<<d.back()<<endl;
}


Measured memory_bytes: 16640
from queue import Queue

n, m = map(int, input().split())
d = {x: [] for x in range(n)}
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[a].append(b)
    d[b].append(a)

visited = [False for x in range(n)]
distance = [float("inf") for x in range(n)]
distance[0] = 0
parent = [-1 for x in range(n)]
que = Queue()
que.put(0)
while not que.empty():
    now = que.get()
    if visited[now]:
        continue
    visited[now] = True
    for _next in d[now]:
        if visited[_next]: continue
        if parent[_next] != -1: continue
        parent[_next] = now + 1
        distance[_next] = min(distance[_next], distance[now] + 1)
        que.put(_next)
print("Yes")
for i in parent[1:]:
    print(i)


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

const int N = 55;

int a[N], x, dp[N][N][N * N];

int f(int idx, int cnt, int val) {
	if(idx == 0) {
		if(cnt) return x * cnt ==  val;
		return 0;
	}
	if(~dp[idx][cnt][val]) return dp[idx][cnt][val];
	return dp[idx][cnt][val] = f(idx - 1, cnt, val) + f(idx - 1, cnt + 1, val + a[idx]);

}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n >> x;
	memset(dp, -1, sizeof dp);
	for(int i = 1; i <= n; i++) cin >> a[i];
	cout << f(n, 0, 0) << endl;
}

Measured memory_bytes: 71808