akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<set>
#include<algorithm>
using namespace std;

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

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

    sort(a,a+k,greater<int>());

    int sum = 0;
    for(int i=0;i<n;++i) sum += a[i];

    cout<<sum<<endl;

}





Measured memory_bytes: 256
// f[i][j][k]  : [1..i] , 3:[1..j] , 2:[j+1..j] , 1:[j+1..i]
#include<bits/stdc++.h>
using namespace std;
#define Mod 1000000007
int n,m,f[301][301][301];
int x[301],y[301],z[301];
int h[301],nxt[301],to[301],tot;
inline void ins(int x,int y){nxt[++tot]=h[x];to[tot]=y;h[x]=tot;}
inline void P(int&x,int y){x+=y;x>=Mod?x-=Mod:0;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		scanf("%d%d%d",x+i,y+i,z+i);
		ins(y[i],i);
	}
	f[1][0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<i;++j){
			for(int k=0;k<=j;++k){
				if(j==k&&j!=0) {f[i][j][k]=0; continue;}
				for(int l=h[i];l;l=nxt[l]){
					int id=to[l];
					if(z[id]==1&&x[id]<=j) f[i][j][k]=0;
					if(z[id]==2&&(x[id]<=k||x[id]>j)) f[i][j][k]=0;
					if(z[id]==3&&x[id]>k) f[i][j][k]=0;
				}
			}
		}
	/*	for(int j=0;j<i;++j){
			for(int k=0;k<=j;++k){
				if(!f[i][j][k]) continue;
				printf("f[%d][%d][%d] = %d\n",i,j,k,f[i][j][k]);
			}
		}
	*/	if(i==n) continue;
		for(int j=0;j<i;++j){
			for(int k=0;k<=j;++k){
				if(!f[i][j][k]) continue;
				P(f[i+1][j][k],f[i][j][k]);
				P(f[i+1][i][j],f[i][j][k]);
				if(j>0) P(f[i+1][i][k],f[i][j][k]);
			}
		}
	}
	int Ans=f[n][0][0]*3ll%Mod;
	for(int j=1;j<n;++j)
		for(int k=0;k<j;++k)
			P(Ans,f[n][j][k]*6ll%Mod);
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 104832
n = int(input())
a = list(map(int, input().split()))

bit_len = 20
memo = [[] for i in range(bit_len)]
ans = 0

for i, ai in enumerate(a):
    li = 0
    for j in range(bit_len):
        if ai & (1 << j):
            if len(memo[j]) >= 1:
                li = max(li, memo[j][-1] + 1)
            memo[j].append(i)
        else:
            if len(memo[j]) >= 2:
                li = max(li, memo[j][-2] + 1)
    ans += i - li + 1

print(ans)


Measured memory_bytes: 119688
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
using namespace std;


int main(){
    fast 
    char x;
    cin>>x;
    if(x<='z'&&x>='a')cout<<'a';
    else cout<<'A';
    
    return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int R = scanner.nextInt();
		if (N >= 10) {
			System.out.println(R);
		} else {
			System.out.println(R + 100 * (10 - N));
		}

	}

}


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

using namespace std;

struct Node {
    int parent;
    int left;
    int right;
    int depth;
    int height;

    Node() : parent(-1), left(-1), right(-1) {}
};

int calculate_depth(vector<Node>& tree, int index) {
    int depth = 0;
    while (tree[index].parent != -1) {
        index = tree[index].parent;
        ++depth;
    }
    return depth;
}

int _calculate_height(vector<Node>& tree, int index) {
    int left_height = 0;
    int right_height = 0;

    if (tree[index].left != -1)
        left_height = _calculate_height(tree, tree[index].left) + 1;
    if (tree[index].right != -1)
        right_height = _calculate_height(tree, tree[index].right) + 1;
    return max(left_height, right_height);
}

int calculate_height(vector<Node>& tree, int index) {
    return _calculate_height(tree, index);
}

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

    vector<Node> tree(n);
    for (int i = 0; i < n; ++i) {
        int id;
        cin >> id;
        cin >> tree[id].left >> tree[id].right;
        tree[tree[id].left].parent = id;
        tree[tree[id].right].parent = id;
    }

    for (int i = 0; i < n; ++i) {
        tree[i].depth = calculate_depth(tree, i);
        tree[i].height = calculate_height(tree, i);

        cout << "node " << i << ": parent = " << tree[i].parent
             << ", sibling = ";
        int parent = tree[i].parent;
        if (parent == -1)
            cout << -1;
        else if (tree[parent].left == i)
            cout << tree[parent].right;
        else
            cout << tree[parent].left;

        cout << ", degree = ";
        int degree = 0;
        if (tree[i].left != -1)
            ++degree;
        if (tree[i].right != -1)
            ++degree;
        cout << degree;

        cout << ", depth = " << tree[i].depth << ", height = " << tree[i].height
             << ", ";

        if (parent == -1)
            cout << "root\n";
        else if (degree == 0)
            cout << "leaf\n";
        else
            cout << "internal node\n";
    }
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int h[55];
int main(){
    int n;
    cin>>n;
    for(int i = 1;i <= n;i++){
        cin>>h[i];
    }
    long long ans = 0;
    for(int i = 1;i <= n;i++){
        for(int j = i + 1;j <= n;j++){
            ans += h[i] * h[j];
        }
    }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int x, a, b;
    cin >> x >> a >> b;
    if (a >= b)
        cout << "delicious\n";
    else if (a + x >= b)
        cout << "safe\n";
    else
        cout << "dangerous\n";
}


Measured memory_bytes: 3624
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* 
   If you know what you’re worth, 
   then go out and get what you’re worth
   But you gotta be willing to take the hits, 
   and not pointing fingers saying you ain’t 
   where you wanna be because of him, or her, or anybody. 
   Cowards do that and that ain’t you. You’re better than that! 
*/

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


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


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

const int inf = 1e18;
const int N = 1e5+5;


int32_t main(){
    FAST;

   int n , k;   cin >> n >> k;
   int h[n];
   for(int i = 0; i < n; i++)   cin >> h[i];
   sort(h , h + n, greater<int>());
   int ans = 0;
   for(int i = k; i < n; i++)
    ans += h[i];
    cout << ans << endl;

    
    return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD =1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N, K;
	cin >> N >> K;

	if (2 * K - 1 <= N) { cout << "YES"; }
	else { cout << "NO"; }

	system("PAUSE");
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define mod 1000000007
#define inf 1e18
#define w(x) int x; cin>>x; while(x--)
using namespace std;
bool sieve[100007];
void sieve_make() 
{
	memset(sieve,true,sizeof(sieve));
	sieve[0]=sieve[1]=false;
	for(int i=2;i*i<=100006;i++)
	{
		if(sieve[i])
		{
			for(int j=2*i;j<=100006;j+=i)
				sieve[j]=false;
		}
	}
}

int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int modexp(int a,int b,int c)
{
	if(a==0) return 0;
	if(b==0) return 1;

	int ans;
	if(b%2==0)
	{
		int small=modexp(a,b/2,c);
		ans=(small*small)%c;
	}
	else
	{
		int small=modexp(a,b-1,c);
		ans=(a%c);
		ans=(small*ans)%c;
	}
	return (ans+c)%c;
}

string rev(string s)
{
	reverse(s.begin(), s.end());
	return s;
}
bool sign(int x)
{
	if(x>0)
		return true;
	return false;
}

int base3(string b)
{
	int ans=0,c=0;
	for(int i=b.length()-1;i>=0;i--)
	{
		ans+=(b[i]-'0')*pow(3,c++);
	}
	return ans;
}

int32_t main()
{
	ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
	
	
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	    
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}

	int dp[n][3];
	
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];

	for(int i=1;i<n;i++)
	{
		int a1=max(a[i]+dp[i-1][1],a[i]+dp[i-1][2]);
		int b1=max(b[i]+dp[i-1][0],b[i]+dp[i-1][2]);
		int c1=max(c[i]+dp[i-1][1],c[i]+dp[i-1][0]);
		dp[i][0]=a1;
		dp[i][1]=b1;
		dp[i][2]=c1;
	}
	
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});

}

Measured memory_bytes: 4992
/*
tags:[贪心][排序][预处理]
贪心地选取一些连续的夏日，在这些连续的夏日里使用冬胎。
a[i]: 第i个冬日，出现在第几天。
b[i] = a[i+1] - a[i] － 1表示两个相邻的冬日之间有多少个连续的夏日。
显然，我们希望连续的夏日时间越短越好，故对b从小到大排序。
*/
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int NICO = 200000 + 10;
int n, m;
char s1[60][60],s2[60][60]; 
int main()
{
    cin >> n >> m;
    for(int i=0;i<n;i++) scanf("%s",s1[i]);
    for(int i=0;i<m;i++) scanf("%s",s2[i]);
    int ok = 0;
    for(int i=0;i<=n-m;i++)
    {
        for(int j=0;j<=n-m;j++)
        {
            int ac = 1;
            for(int a=i;a<i+m;a++)
            {
                for(int b=j;b<j+m;b++)
                {
                    if(s1[a][b] != s2[a-i][b-j])
                    {

                        ac = 0;
                    }
                }
            }
            if(ac) ok = 1;
        }
    }
    cout << (ok?"Yes":"No") << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc147/submissions/8853537
// https://outline.hatenadiary.jp/entry/2019/12/17/021530
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

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

    int cnt = 1;
    while (n >= k) {
        n /= k;
        cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Sun Mar 22 11:54:41 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

l = ni()

p = l % 3
ans = (l / 3) * (l / 3) * (l / 3)
print(ans)

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
    int A, B;
    cin >> A >> B;
    if (A * B * 1 & 1) {
        cout << "Yes" << endl;
        return;
    }
    if (A * B * 2 & 1) {
        cout << "Yes" << endl;
        return;
    }
    if (A * B * 3 & 1) {
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long k = scan.nextLong();
        int q = scan.nextInt();
        int[] a = new int[q];
        long[] point = new long[n];
        for (int i = 0; i < q; i++) {
            point[scan.nextInt()-1] += 1;
        }
        for (int i = 0; i < n; i++) {
            long cnt = (point[i] + k) - q;
            String message = cnt > 0 ? "Yes" : "No";
            System.out.println(message);
        }

    }
}

Measured memory_bytes: 59720
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);
typedef long long LL;

LL N;
vector<LL> X, Y, P, Q;
int done[52] = {0};

LL sameClass(LL u1, LL v1, LL u2, LL v2, LL p, LL q){
	LL ret = INF;
	LL du = u2 - u1;
	LL dv = v2 - v1;
	if(p != 0 && (du % p) == 0){
		LL a = du / p;
		if(dv == a*q){
			ret = a;
		}
	}
	if(p == 0 && du == 0){
		LL a = dv / q;
		ret = a;
	}
	return ret;
}

LL calcCost(LL x, LL y, LL p, LL q){
	vector<LL> v;
	for(int i=0; i<N; i++){
		if(x == X[i] && y == Y[i]){
			if(done[i] == 1){
				return 0LL;
			}
			else{
				continue;
			}
		}
		LL r = sameClass(x, y, X[i], Y[i], p, q);
		if(r != INF){
			v.push_back(r);
			done[i] = 1;
		}
	}
	v.push_back(0);
	sort(v.begin(), v.end());
	LL cost = 1;
	for(int i=1; i<v.size(); i++){
		if((v[i] - v[i-1]) != 1){
			cost++;
		}
	}
	return cost;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i=0; i<N; i++){
		LL x, y;
		cin >> x >> y;
		X.push_back(x);
		Y.push_back(y);
	}

	if(N == 1){
		printf("1\n");
		return 0;
	}

	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			LL p = X[j] - X[i];
			LL q = Y[j] - Y[i];
			P.push_back(p);
			Q.push_back(q);
			P.push_back(p*(-1));
			Q.push_back(q*(-1));
		}
	}

	LL mincost = INF;
	for(int i=0; i<P.size(); i++){
		LL cost = 0;
		LL aP = P[i];
		LL aQ = Q[i];
		for(int j=0; j<N; j++){
			if(done[j] == 1){ continue; }
			cost += calcCost(X[j], Y[j], aP, aQ);
			done[j] = 1;
		}
		if(mincost > cost){
			mincost = cost;
		}
		for(int j=0; j<N; j++){
			done[j] = 0;
		}
	}
	printf("%lld\n", mincost);
	return 0;
}


Measured memory_bytes: 3776
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	scanf("%d %d",&n,&m);
	printf("%d\n",(n-1)*(m-1));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
using ll=long long;

using namespace std;
using P=pair<int,int>;
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); }
int main(){
    int n,s;
    cin>>n>>s;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    const ll MOD=998244353;
    vector<ll> dp(s+1);
    dp[0]=modpow(2,n,MOD);
    for(int i=0;i<n;i++){
        for(int j=s;j>=0;j--){
            if(j+a[i]<=s){
                dp[j+a[i]]+=dp[j]*modinv(2,MOD);
                dp[j+a[i]]%=MOD;
            }
        }
    }
    cout<<dp[s]<<endl;
}



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

using namespace std;



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

    int n;
    cin >> n;

    vector<int> v;
    int x;

    for (int i = 0; i < n; ++i) {
        cin >> x;

        v.push_back(x);
    }

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

    int l = 0, L = 0;

    for (vector<int>::reverse_iterator it = v.rbegin(); it != v.rend(); ++it) {
        if (*it == *(it + 1)) {
            if (L == 0) L = *it, ++it;
            else {
                l = *it;
                cout << L * 1LL * l;
                return 0;
            }
        }
    }

    cout << 0;

    return 0;
}


Measured memory_bytes: 892
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] a = in.next().toCharArray();

            // see if doubles.
            int start = -1;
            int end = -1;

            for (int i = 1; i < a.length; i++) {
                if (a[i] == a[i - 1]) {
                    start = i;
                    end = i + 1;
                    break;
                }
            }

            if (start != -1) {
                out.println(start + " " + end);
                return;
            } else {
                for (int i = 2; i < a.length; i++) {
                    if (a[i] == a[i - 2]) {
                        start = i - 1;
                        end = i + 1;
                        out.println(start + " " + end);
                        return;
                    }
                }
            }
            out.println(start + " " + end);
        }
    }
}


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

#define ll  long long int

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>



void boost()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll mod=1e9+7;



int main()
{
    
    boost();
    ll n,i,j,t,x,y,m,k;
    cin>>n>>k;
    ll a[n],dp[n]={0};
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        dp[i]=1e18;
        for(j=1;j<=k;j++)
        {
            if(i-j<0)
                continue;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
        if(i==0)
            dp[i]=0;
        //cout<<dp[i]<<" ";
    }
    //cout<<endl;
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
const int MOD = 1000000007;
const int INF = 1000000000;
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; }

int main(){
    int a; cin >> a;
    string s; cin >> s;
    cout << (a<3200 ? "red" : s) << "\n";
    return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int a[35];
int main()
{
  int n, m, k, b, ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &k);
    for (int j = 0; j < k; j++)
    {
      scanf("%d", &b);
      a[b - 1]++;
    }
  }
  for (int i = 0; i < m; i++)
  {
    if (a[i] == n)
      ans++;
  }
  printf("%d\n", ans);
  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<ll,ll>;

int N;
P ps[200100];

bool can(){
    ll t = 0;
    
    for(int i=0;i<N;++i){
        ll B, A;
        std::tie(B, A) = ps[i];

        t += A;

        if(t > B){
            return false;
        }
    }

    return true;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        ll A, B;
        std::cin >> A >> B;

        ps[i] = std::make_tuple(B, A);
    }

    std::sort(ps, ps + N);

    if(can()){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

bool pairCompare(const pair<ll, ll>& firstElof, const pair<ll, ll>& secondElof) {
    return firstElof.first < secondElof.first;
}

int main() {
    ll n, m;
    cin >> n >> m;
    int ans = 0;
    if ( m == 0 ) {
        if ( n != 1 ) {
            ans = pow(10, n-1);
        }
        cout << ans << endl;
        return 0;
    }
    ll s[m], c[m];
    ll Ans[n] = {};
    vector<pair<ll, ll> > pairs;

    int j = 1;
    rep(i, m) {
        cin >> s[i] >> c[i];
        if ( n != 1 && s[i] == 1 && c[i] == 0 ) {
            j = 0;
        }
        pairs.push_back( make_pair(s[i], c[i]) );
    }
    if (!j) {
        cout << -1 << endl;
        return 0;
    }

    sort(ALL(pairs), pairCompare);

    rep(i, m) {
        if ( i == 0 ) {
            Ans[pairs.at(i).first-1] = pairs.at(i).second;
        } else {
            if ( Ans[pairs.at(i).first-1] != 0 ) {
                if ( Ans[pairs.at(i).first-1] != pairs.at(i).second ) {
                    j = 0;
                    break;
                }
            } else {
                Ans[pairs.at(i).first-1] = pairs.at(i).second;
            }
        }
    }

    if (!j) {
        cout << -1 << endl;
        return 0;
    }
    if ( n > 1 && Ans[0] == 0 ) {
        Ans[0] = 1;
    }

    if ( Ans[0] != 0 || Ans[1] != 0 || Ans[2] != 0 ) {
        rep(i, n) {
/*
            if ( Ans[i] != 0 && i != n-1 ) {
                ans += Ans[i]*pow(10, n-i-2);
            } else if ( i == n-1 ) {
                ans *= 10;
                ans += Ans[i];
*/
            cout << Ans[i];
        }
    } else {
        ans += pow(10, n-1);
    }

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string N;
    cin >> N;
    int cnt = 0;
    for (auto c : N) {
        if (c == '2') cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import math
def koch(n, p1, p2):
    if n == 0:
        return
    sx = (2*p1[0]+p2[0])/3
    sy = (2*p1[1]+p2[1])/3
    s = (sx, sy)
    tx = (p1[0]+2*p2[0])/3
    ty = (p1[1]+2*p2[1])/3
    t = (tx, ty)
    ux = (tx-sx)*math.cos(math.pi/3) - (ty-sy)*math.sin(math.pi/3) + sx
    uy = (tx-sx)*math.sin(math.pi/3) + (ty-sy)*math.cos(math.pi/3) + sy
    u = (ux, uy)
    koch(n-1, p1, s)
    print(s[0], s[1])
    koch(n-1, s, u)
    print(u[0], u[1])
    koch(n-1, u, t)
    print(t[0], t[1])
    koch(n-1, t, p2)
n = int(input())
p1 = (0, 0)
p2 = (100, 0)
print(0, 0)
koch(n, p1, p2)
print(100, 0)


Measured memory_bytes: 5776
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a % b);
}


long long calc(long long lower, long long upper, long long divisor) {
	return upper / divisor - (lower - 1) / divisor;
}


int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	long long lcm = c / gcd(c, d) * d;

	long long ans = 0;
	long long n_c = calc(a, b, c);
	long long n_d = calc(a, b, d);
	long long n_lcm = calc(a, b, lcm);

	// cout << n_c << endl;
	// cout << n_d << endl;
	// cout << n_lcm << endl;

	ans = b - a + 1 - (n_c + n_d - n_lcm);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  string S;
  cin >> S;
  vector<int> v(26, 0);
  for (auto s: S){
      v[s - 'A']++;
  }
  string ans = "Yes";
  for (auto e: v){
    if (not (e == 0 || e == 2))
      ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main() {
	int n = in();
	cout << "0:" << endl;
	REP1(i, pow(2, n) - 1) {
		cout << i << ':';
		int i_copy = i;
		for (int j = 0; i_copy > 0; ++j) {
			if (i_copy % 2 == 1)cout << ' ' << j;
			i_copy >>= 1;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3268
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int  n,p[1000],k,sum=0;
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>p[i];
  sort(p,p+n);
  for(int i=0;i<k;i++)
    sum+=p[i];
  cout<<sum;
  return 0;}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int N;
vector<long long int> a, b, V;

long long int c[33];

int main(void) {

	cin >> N;
	long long int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp; a.push_back(tmp);
	}
	for (int i = 0; i < N; i++) {
		cin >> tmp; b.push_back(tmp);
	}

	long long int M = 1;
	long long int num;
	for (int k = 0; k <= 32; k++) {
		M *= 2; V.clear();
		for (int i = 0; i < N; i++) { V.push_back(a[i] % M); }
		//cout << "V "; for (int i = 0; i < N; i++) { cout << " " << V[i]; }cout << endl;
		sort(V.begin(), V.end());
		num = 0;
		for (int j = 0; j < N; j++) {
			num += upper_bound(V.begin(), V.end(), M - 1-(b[j]%M)) - lower_bound(V.begin(), V.end(), M / 2-(b[j]%M));
			num += upper_bound(V.begin(), V.end(), 2 * M - 1-(b[j]%M)) - lower_bound(V.begin(), V.end(), M + M / 2-(b[j]%M));
		}
		c[k] = num;
	}


	long long int ans=0;

	for (int k = 32; k >= 0; k--) {
		//cout << c[k];
		ans = 2 * ans + (c[k]%2);
	}
	
	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 7636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

int main(void) {
    string s;
    cin >> s;
    int length = s.size();
    VI count(26, 0);
    int min = 1e09;

    for (int i = 0; i < s.size(); i++) {
        count[(int)(s[i] - 'a')]++;
    }
    for (int i = 0; i < 26; i++) {
        if (count[i] == 0) {
            continue; 
        }
        if (count[i] == length){
            min = 0;
            break;
        }

        int temp_length = length;
        string temp_s = s;

        while (1) {
            string ans(temp_length - 1, i + 'a');
            string new_s(temp_length - 1, '0');
            for (int j = 0; j < new_s.size(); j++) {
                if (temp_s[j] == i + 'a' || temp_s[j + 1] == i + 'a') {
                    new_s[j] = i + 'a';
                } else {
                    new_s[j] = temp_s[j];
                }
            }

            if (new_s == ans) {
                if (min >  length - new_s.size()) {
                    min = length - new_s.size();   
                }
                break;
            } else {
                temp_s = new_s; 
                temp_length--;
            }
        }
    }
    cout << min << endl;
    return 0;
}



Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         char[][] grid = new char[N][M];
         for(int i=0; i < N; i++)
            grid[i] = infile.readLine().toCharArray();
         int res = 0;
         for(int mask1=0; mask1 < (1<<N); mask1++)
            for(int mask2=0; mask2 < (1<<M); mask2++)
            {
               int cnt = 0;
               for(int r=0; r < N; r++)
                  for(int c=0; c < M; c++)
                     if(grid[r][c] == '#' && (mask1&(1<<r)) == 0 && (mask2&(1<<c)) == 0)
                        cnt++;
               if(cnt == K)
                  res++;
            }
         System.out.println(res);
      }
   }

Measured memory_bytes: 32664
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
ll mod= 1e9 + 7;


int main(){
  int h,w;
  cin >> h>> w;
  char a[h][w];//たて、よこ
  bool b[h]={},c[w]={};
  rep(i,h){
    rep(r,w){
      cin >> a[i][r];
    }
  }

  rep(i,h){
    int g=0;
    rep(r,w){
      if(a[i][r]=='#')g++;
    }
    if(g==0)b[i]=1;
  }
  rep(i,w){
    int g=0;
    rep(r,h){
      if(a[r][i]=='#')g++;
    }
    if(g==0)c[i]=1;
  }

  rep(i,h){
    rep(r,w){
      if(b[i]==0 && c[r]==0){cout << a[i][r];}
    }
    if(b[i]==0)cout << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  double n,m,d;
  cin>>n>>m>>d;
  printf("%lf\n",(double)(2-(int)(d==0))*(n-d)*(m-(double)1)/n/n);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int a[200][200];
int b[200];
int n,m;

int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)cin>>a[i][j];
    }
    for(int i=1;i<=m;i++)cin>>b[i];
    for(int i=1;i<=n;i++){
        int val=0;
        for(int j=1;j<=m;j++)val+=a[i][j]*b[j];
        cout<<val<<endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int lcs(string X, string Y) {
    int m = X.size();
    int n = Y.size();
    int c[m+1][n+1];
    int maxl = 0;
    X = ' ' + X;    // insert empty to X[0]
    Y = ' ' + Y;    // insert empty to Y[0]
    for (int i = 0; i <= m; i++) { c[i][0] = 0; }
    for (int j = 1; j <= n; j++) { c[0][j] = 0; }

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (X[i] == Y[j]) {
                c[i][j] = c[i-1][j-1] + 1;
            } else {
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
        }
    }

    return c[m][n];
}

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

    for (int i = 0; i < n; i++) {
        string s1, s2;
        cin >> s1 >> s2;
        printf("%d\n", lcs(s1, s2));
    }
    return 0;
}


Measured memory_bytes: 7152
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

  int N, M, C;
  cin >> N >> M >> C;

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < M; j++) {
      int a;
      cin >> a;

      sum += (a * b[j]);
    }

    if (sum + C > 0) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  ll k = 1;
  while(true){
    if(k*k>n){
      k--;
      break;
    }
    k++;
  }
  cout << k*k << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl

int solve(vector <string> &v, int n, int m)
{
	vector < vector <int> > dp(n+1,vector <int>(m+1,0));
	int modu = 1000000007;
	dp[0][0]=1;
	forn(i,n)
	{
		forn(j,m)
		{
			if(v[i][j]=='#') continue;
			if(i > 0) {dp[i][j]+=dp[i-1][j]; dp[i][j]%=modu;}
			if(j > 0) {dp[i][j]+=dp[i][j-1]; dp[i][j]%=modu;}
		}
	}
	return dp[n-1][m-1];
	
}
 
int main()
{ 
	FIN;
	
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif
	
	int n, m;
	cin >> n >> m;
	vector <string> v(n);
	forn(i,n) cin >> v[i];
	cout << solve(v,n,m) << endl;
	return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define leng(n) (int)(log10(n)+1)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    string s;
    cin>>s;
    int n=s.size();
    VVi dp(n+1,Vi(13));
    dp[0][0]=1;
    REP(i,0,n){
        REP(j,0,13){
            if(s[i]=='?'){
                REP(k,0,10){
                    dp[i+1][((10*j)+k)%13] = (dp[i+1][((10*j)+k)%13]+dp[i][j])%MOD;
                }
            }else{
                dp[i+1][((10*j)+ctoi(s[i]))%13] = (dp[i+1][((10*j)+ctoi(s[i]))%13]+dp[i][j])%MOD;
            }
        }
    }
//    vvout(dp);
    cout<<dp[n][5]<<endl;
}


Measured memory_bytes: 13776
#include <stdio.h>
int main(void)
{
int a, b;

while(1){
scanf("%d %d",&a,&b);
if(a == 0 && b == 0){
break;
}

if(a > b)
printf("%d %d",b,a);

else
printf("%d %d",a,b);

printf("\n");
}
return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cctype>
#include <cmath>
#include <fstream>

using namespace std;

typedef long long ll;
#define REP(i,k) for(int (i)=0;(i)<(k);(i)++)
#define INF ~(1<<31)
#define CLR(a) memset((a),0,sizeof((a)))
#define EPS 1e-9
#define DBG 1
#define D(s,v) if(DBG) cout<<(s)<<": "<<(v)<<endl;
#define DVEC(s,v) if(DBG) {cout<<(s)<<": "; for(int i=0;i<(v).size();i++) cout<<(v)[i]<<" "; cout<<endl;}
#define DARR(s,v,n) if(DBG) {cout<<(s)<<": "; for(int i=0;i<n;i++) cout<<(v)[i]<<" "; cout<<endl;}

int main(){
    ios_base::sync_with_stdio(0);

    int N, A;
    while(cin>>N>>A){
        if(N<=A) cout<<"Yes"<<endl;
        else if(N%500 <= A) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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


//using ll = long long;
int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main(void)
{
	int n, k;
	int okasi[100], d, keep;
	scanf("%d%d",&n,&k);
	for (int i = 1; i <= n; i++) {
		okasi[i] = 0;
	}
	for (int i = 0; i < k; i++) {
		scanf("%d",&d);
		for (int j = 0; j < d; j++) {
			scanf("%d",&keep);
			okasi[keep] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (okasi[i] != 1)
			ans++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 10e9+7
#define int int64_t

signed main(){
	int l,r;
	cin>>l>>r;
	int ans=2019;
	for(int i=l;i<=r;i++){
		for(int j=i+1;j<=r;j++){
			ans=min(ans,i*j%2019);
			if(ans==0){cout<<0<<endl;return 0;}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
  by Guille
*/
#include <bits/stdc++.h>

using namespace std;

#define fo(i,n) for(int i=0;i<n;i++)
#define fa(i,I,n) for(int i=I;i<n;i++)
#define sz(x) x.size()
#define sc(x) scanf("%d",&x)
#define mos(x) cout<<#x<<" = "<<x<<endl;
#define zero(x) memset(x,0,sizeof(x))
#define mone(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define p push
#define ll long long
#define pb push_back
#define N 400005

const double pi=acos(0)*2.,err=1e-12;
const int oo=1<<28;
typedef pair<int,int> pii;
typedef vector<int> vi;

int n;

int main(){
    sc(n);
    printf("%d:",n);
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                printf(" %d",i);
                n/=i;
            }
        }
    }
    if(n>1)printf(" %d",n);
    printf("\n");
    return 0;
}

Measured memory_bytes: 1196
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<utility>
#include<algorithm>
using namespace std;

typedef long long ll;
int win[10], lose[10], table[10][10], save[50], n, m, k, ans;

void dfs(int x,int f)
{
	if (x == k + 1)
	{
		int ok = 1;
		for (int i = 1; i <= n; i++)
			if (win[i] != n / 2 || lose[i] != n / 2) ok = 0;
		if (ok) ans++;
		return;
	}
	int i = save[x] / n + 1; int j = save[x]%n + 1;
	if (f == 1)
	{
		win[i]++; lose[j]++;
	}
	else
	{
		win[j]++; lose[i]++;
	}
	if (win[i] > n / 2 || lose[i] > n / 2 || win[j] > n / 2 || lose[j] > n / 2)
	{
		if (f == 1)
		{
			win[i]--; lose[j]--;
			return;
		}
		else
		{
			win[j]--; lose[i]--;
			return;
		}
	}
	dfs(x + 1, 1);
	dfs(x + 1, 0);
	if (f == 1)
	{
		win[i]--; lose[j]--;
	}
	else
	{
		win[j]--; lose[i]--;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	while (1)
	{
		cin >> n >> m;
		if (!n) break;
		memset(win, 0, sizeof(win));
		memset(lose, 0, sizeof(lose));
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				table[i][j] = -1;
		for (int i = 1; i <= m; i++)
		{
			int x, y;
			cin >> x >> y;
			table[x][y] = 1; table[y][x] = 0;
			win[x]++; lose[y]++;
		}
		k = 0;
		for (int i = 1; i <= n; i++)
			for (int j = i + 1; j <= n; j++)
				if (table[i][j] == -1) save[++k] = (i - 1)*n + j - 1;
		ans = 0;
		dfs(1, 1);
		dfs(1, 0);
		cout << ans/2 << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include <math.h>
#include <iostream>
using namespace std;

const int MAX = 1e6;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int x, y;
  cin >> x >> y;
  if(x < 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  }
  int ta, tb;
  ta = 2 * y - x;
  tb = 2 * x - y;
  if (ta % 3 != 0 || ta % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  long long a = ta / 3;
  long long b = tb / 3;
  COMinit();
  cout << COM(a + b, b) << endl;
  return 0;
}

Measured memory_bytes: 23680