akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define popb pop_back
#define ub upper_bound
#define lb lower_bound
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mmin(x) memset((x),-1,sizeof((x)))
#define mnul(x) memset((x),0,sizeof((x)))
#define N 2005
//const int inf= 1000000005;
//const int MOD= 1000000007;
//const int N= 2005;

char a[N][N];
int v[N][N],e[N][N];
int er[N][N],ec[N][N];

int getver(int a,int b,int c,int d){
	return v[c][d]+v[a-1][b-1]-v[a-1][d]-v[c][b-1];
}

int geted(int a,int b,int c,int d){
	int ret=e[c][d]+e[a-1][b-1]-e[a-1][d]-e[c][b-1];
	ret-=(er[a][d]-er[a][b-1]);
	ret-=(ec[c][b]-ec[a-1][b]);
	return ret;
}

int main(){
	int n,m,q;
	scanf("%d %d %d",&n,&m,&q);
	getchar();
	mnul(a);mnul(v);mnul(e);
	mnul(er);mnul(ec);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%c",&a[i][j]);
			v[i][j]=v[i-1][j]+v[i][j-1]-v[i-1][j-1];
			e[i][j]=e[i-1][j]+e[i][j-1]-e[i-1][j-1];
			er[i][j]=er[i][j-1];
			ec[i][j]=ec[i-1][j];
			if(a[i][j]=='0')continue;
			v[i][j]++;
			if(i>1 && a[i-1][j]=='1'){ e[i][j]++; er[i][j]++;}
			if(j>1 && a[i][j-1]=='1'){ e[i][j]++; ec[i][j]++;}
		}
		getchar();
	}
	for(int i=0;i<q;i++){
		int x1,x2,y1,y2;
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		int ed=geted(x1,y1,x2,y2);
		int ver=getver(x1,y1,x2,y2);
		printf("%d\n",ver-ed);
	}
}


Measured memory_bytes: 68608
N,K = map(int, input().split())
A = [*map(lambda x:int(x)-1, input().split())]

cnt, pre = [0]*N, 0
for _ in range(N*2):
    cnt[pre] += 1
    pre = A[pre]

one, loops = 0, 0
for c in cnt:
    if c == 1: one += 1
    elif c > 1: loops += 1

k = max(0, K-one) % loops + min(K, one)

pre = 0
for _ in range(k): pre = A[pre]
print(pre + 1)


Measured memory_bytes: 32376
#include<iostream>
#include<vector>

using namespace std;
bool rinear_search(vector<int> S,size_t n,int key){
 int  count=0;
   for(size_t j=0; j< n; j++){
      if(key ==S[j]) {
        return true;
      }
  }
return false;
}

int main(){
 size_t n,q;
 int count=0,key=0;
 cin >> n;
 vector<int> S(n);
  for(size_t i=0;i< n ; i++ ){
    cin>> S[i];
  }
  cin>> q;
  vector<int> T(q);
 for(size_t j=0;j< q ; j++) {
     cin >> T[j];
     key = T[j];
  if(rinear_search(S,n,key)==true){
  count++;
  }
 }

  cout<< count<< endl;


 return 0;

}



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

using namespace std;

int main (void) {
    long long A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;

    long long first_dist = abs(A - B);
    long long v_diff = V - W;

    if ( first_dist <= v_diff * T )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

const int MAX=100005;
const ll oo=1e18;
ll dp[105][MAX];
int weights[MAX];
int value[MAX];
int W,n;

ll bag(int i,int w){
    if(w>W) return -oo;
    if(i==n) return 0;
    if(dp[i][w]!=-1) return dp[i][w];
    dp[i][w]=max(bag(i+1,w),bag(i+1,w+weights[i])+value[i]);
    return dp[i][w];
}

int main() {
    #ifndef LOCAL
    fastIO;
    #endif
    memset(dp,-1,sizeof(dp));
    cin >> n >> W;
    for(int i=0;i<n;i++){
        cin >> weights[i] >> value[i];
    }
    cout << bag(0,0) << endl;
    return 0;
}



Measured memory_bytes: 85676
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <random>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB") {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	print(n*(n-1)/2+m*(m-1)/2);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){ 
    int n,a,b;
    scanf("%d",&n);
    a=100*n/108;
    b=a+1;
    if(100*n%108==0)
    printf("%d",a);
    else if(100*n%108>0&&108*a/100==n)
    printf("%d",a);
    else if(100*n%108>0&&108*b/100==n)
    printf("%d",b);
    else
    {
        printf(":(");
    }
    
    return 0;
}

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

int main(void) {

    int h, w;
    scanf("%d %d", &h, &w);
    char s[101];

    char a[h][101];
    for (int i = 0; i < h; i++) {
        scanf("%s", s);
        strcpy(a[i], s);
    }


    for (int i = 0; i < w + 2; i++) {
        printf("%c", '#');
    }
    printf("\n");
    for (int j = 0; j < h; j++) {
        printf("#%s#\n", a[j]);
    }
    for (int i = 0; i < w + 2; i++) {
        printf("%c", '#');
    }

    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

int get_int(){int x;scanf("%d",&x);return x;}
LL get_long(){LL x;scanf("%lld",&x);return x;}

int N;
vector<int> A;
vector<int> B;

int main()
{
    LL val = 0;
    scanf("%d",&N);
    _for(i,0,N){
        int n = get_int();
        A.push_back(n);
    }
    _for(i,0,N){
        int n = get_int();
        B.push_back(n);
    }
    _for(i,0,N){
        int j = A[i] - B[i];
        if(j < 0){
            val += abs(j)/2;
        }
        else{
            val -= j;
        }
    }
    if(val >= 0) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>
using namespace std;
#define INF 2000000000
#define N 10005
#define sz(b) (int)(b.size())
#define pb push_back
int visit[N],d[N],n,m;
typedef pair<int,int> p;
vector<int>a[N],w[N],c[N];
priority_queue<p,vector<p>,greater<p> >q;
void make()
{
    int from,to,d,v;
    for(int i=1;i<=n;i++)
    {
        c[i].clear();
        a[i].clear();
        w[i].clear();
    }
    for(int i=0;i<m;i++)
    {
        scanf("%d%d%d%d",&from,&to,&d,&v);
        a[from].pb(to);
        a[to].pb(from);
        w[from].pb(d);
        w[to].pb(d);
        c[from].pb(v);
        c[to].pb(v);
    }
}
void dijkstra()
{
    for(int i=1;i<=n;i++) d[i]=(i==1?0:INF);
    memset(visit,0,sizeof(visit));
    q.push(make_pair(d[1],1));
    while(!q.empty())
    {
        p u=q.top();
        q.pop();
        int x=u.second;
        if(visit[x]) continue;
        visit[x]=1;
        for(int i=0;i<sz(a[x]);i++)
        {
            int y=a[x][i];
            if(d[y]>d[x]+w[x][i])
            {
                d[y]=d[x]+w[x][i];
                q.push(make_pair(d[y],y));
            }
        }
    }
}
int main()
{
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if(n==0&&m==0) break;
        make();
        dijkstra();
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            int minv=INF,ok=0;
            for(int j=0;j<sz(a[i]);j++)
            {
                if(d[a[i][j]]-d[i]<0&&abs(d[a[i][j]]-d[i])==w[i][j]) {ok=1;minv=min(c[i][j],minv);}
            }
            if(ok==1) ans+=minv;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 4032
k = gets.chomp.to_i
n = 50
ret = (0...n).to_a

x = k / n
rem = k % n

ret.map!{|i| i + x}

rem.times do |i|
  amin = ret.min
  imin = ret.index(amin)
  ret.map!{|e| e - 1}
  ret[imin] += (n + 1)
end

puts n
puts ret.join(" ")

Measured memory_bytes: 1788
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
(declaim (optimize (speed 3) (safety 0) (debug 0)))

(defvar a (read))
(defvar b (read))
(defvar c (read))
(defvar k (read))

(princ (cond ((<= k a) k)
	     ((<= k (+ a b)) a)
	     (t (+ a a b (- k)))))


Measured memory_bytes: 24392
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define ms(a, b)  memset((a), (b), sizeof(a))
//#define LOCAL
typedef long long LL;
const int inf = 0x3f3f3f3f;
const int maxn = 10000+10;
const LL mod = 1000000000+7;

int main()
{
    #ifdef LOCAL
        freopen("input.txt" , "r", stdin);
    #endif // LOCAL
    string a, b;
    cin >> a >> b;
    int n1 = a.size(),n2=b.size();
    int j1=0, j2=0;
    for(int i = 1;i<=n1+n2;i++)
    {
        if(i&1==1)  cout << a[j1++];
        else    cout << b[j2++];
    }
    cout <<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc177
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc177C1();
            Console.Out.Flush();
        }

        public static void solve_abc177C1()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            long mod = 1000000007;
            long sum = a[0];
            long ans = 0;
            for (int i = 1; i < n; i++)
            {
                ans = (ans + ((sum * a[i]) % mod)) % mod;
                sum = (sum + a[i]) % mod;
            }

            Console.WriteLine(ans);
        }

        public static void solve_abc177B()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int min = 10001;
            for (int i = 0; i < s.Length - t.Length + 1; i++)
            {
                int cnt = 0;
                int j = 0;
                while (j < t.Length)
                {
                    if (s[i + j] != t[j])
                    {
                        cnt++;
                    }
                    j++;
                }
                min = Math.Min(min, cnt);
            }

            Console.WriteLine(min);
        }

        public static void solve_abc177A()
        {
            int[] dts = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int d = dts[0];
            int t = dts[1];
            int s = dts[2];
            double taken = (double)d / s;
            Console.WriteLine(taken > t ? "No" : "Yes");
        }

        public static int binSerachLeft(int[] a, int x)
        {
            int l = -1;
            int r = a.Length;
            while (r > l + 1)
            {
                int m = (l + r) / 2;
                if (a[m] <= x)
                {
                    l = m;
                }
                else
                {
                    r = m;
                }
            }
            return l;
        }
    }
}

Measured memory_bytes: 47284
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
string s;
int main()
{
	cin >> s;
	if(s == "SUN"){
		printf("%d", 7);
	}else if(s == "SAT"){
		printf("1");
	}else if(s == "MON"){
		printf("6");
	}else if(s == "TUE"){
		printf("5");
	}else if(s == "WED"){
		printf("4");
	}else if(s == "THU"){
		printf("3");
	}else if(s == "FRI"){
		printf("2");
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int a,b,c;
void input()
{
    cin>>a>>b>>c;
    return;
}

void solve()
{
    string ans;
    if(a==b && b!=c) ans="Yes"; 
    else if(a==c && b!=c) ans="Yes"; 
    else if(b==c && a!=b) ans="Yes"; 
    else ans="No";
    cout<<ans<<endl;
    return;
}

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

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

# F=Fukuzawa H=Higuchi S=Souseki
flg = False
for f in range(N+1):
    for h in range(N+1-f):
        if f * 10000 + h * 5000 + (N - f - h) * 1000 == Y and N-f-h >= 0:
            print("{} {} {}".format(f, h, (N - f - h)))
            flg = True
            break
    if flg is True:
        break

if flg is False:
    print("-1 -1 -1")


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

map<char, set<ll> > aaa;

void solve() {
  ll N;
  cin >> N;
  rep (i, N) {
    char a;
    ll b;
    cin >> a >> b;
    aaa[a].insert(b);
  }
  for (ll i = 1; i <= 13; i++) if (aaa['S'].count(i) == 0) cout << "S " << i << endl;
  for (ll i = 1; i <= 13; i++) if (aaa['H'].count(i) == 0) cout << "H " << i << endl;
  for (ll i = 1; i <= 13; i++) if (aaa['C'].count(i) == 0) cout << "C " << i << endl;
  for (ll i = 1; i <= 13; i++) if (aaa['D'].count(i) == 0) cout << "D " << i << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

  const int inf = 1000000007;

  vector<vector<int> > dp(411, vector<int>(411, inf));
  dp[0][0] = 0;
  for (int k = 0; k < n; k++) {
    for (int i = 400; i >= 0; i--) {
      for (int j = 400; j >= 0; j--) {
        dp[i+a[k]][j+b[k]] = min(dp[i+a[k]][j+b[k]], dp[i][j] + c[k]);
      }
    }
  }

  int alpha = ma;
  int beta = mb;
  int ans = inf;
  while (alpha <= 400 && beta <= 400) {
    ans = min(ans, dp[alpha][beta]);
    alpha += ma;
    beta += mb;
  }

  if (ans == inf) cout << -1 << endl; // impossible
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 896
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;

public class Main {
    public static void main(String[] args)throws Exception {
        StringBuilder sb = new StringBuilder();
        FastReader in = new FastReader(System.in);
        int i, j;
        boolean ok=false;
        int t=ok?in.nextInt():1;
        while(t-->0){
           char arr[]=in.next().toCharArray();
           int n=arr.length;
           int x=0;
           j=0;
           for(char ch:arr){
               if(ch=='?')
                   arr[j]='D';
               sb.append(arr[j]);
               j++;
           }
           sb.append("\n");
        }
        System.out.print(sb);

    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}
 
 

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll aaa(ll n, ll k){
    if (k % 2 == 0) k /= 2;
    // fprintf(stderr, "aaa=%lld\n", n/k);
    return n / k;
}
ll aab(ll n, ll k) {
    // a < b
    ll h = (k % 2 == 0) ? k/2 : k;
    ll cnt = 0;
    for (ll a=h; a<=n; a+=h) {
        cnt += (n-a)/k;
    }
    // fprintf(stderr, "aab=%lld\n", cnt);
    return cnt;
}
ll abb(ll n, ll k) {
    // a < b
    ll h = (k % 2 == 0) ? k/2 : k;
    ll cnt = 0;
    for (ll b=h; b<=n; b+=h) {
        cnt += (b-1)/k;
    }
    // fprintf(stderr, "abb=%lld\n", cnt);
    return cnt;
}
ll abc(ll n, ll k) {
    // a < b < c
    ll h = (k % 2 == 0) ? k/2 : k;
    ll cnt = 0;
    for (ll a=h; a<=n; a+=h) {
        ll d = (n-a)/k;
        cnt += d * (d-1) / 2;
    }
    // fprintf(stderr, "abc=%lld\n", cnt);
    return cnt;
}

ll solve(ll n, ll k) {
    return aaa(n,k) + aab(n,k)*3 + abb(n,k)*3 + abc(n,k)*6;
}

int main() {
    int n, k; cin >> n >> k;
    cout << solve(n,k) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int distance(int a, int b, int c, int d)
{
    return abs(a - c) + abs(b - d);
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a.at(i) >> b.at(i);
    rep(i, m) cin >> c.at(i) >> d.at(i);
    // vector<vector<int>> person(n, vector<int>(3)), checkpoint(m,vector<int>(4));
    // rep(i,n){
    // cin >> person.at(i).at(0) >> person.at(i).at(1);
    // person.at(i).at(2) = abs(person.at(i).at(0)) +
    // }

    for (int i = 0; i < n; i++)
    {
        int check_point = 0;
        int min_distance = INT_MAX;
        for (int j = 0; j < m; j++)
        {
            if (min_distance > distance(a.at(i), b.at(i), c.at(j), d.at(j)))
            {
                min_distance = distance(a.at(i), b.at(i), c.at(j), d.at(j));
                check_point = j + 1;
            }
        }
        cout << check_point << endl;
    }
}

Measured memory_bytes: 256
program katana_thrower
  implicit none
  integer :: n, i
  integer(8) :: h, a(100000), b(100000), am, bm, m
  a = 0_8
  b = 0_8
  read(*,*) n, h
  am = 0_8
  do i = 1, n
    read(*,*) a(i), b(i)
    if (am.lt.a(i)) am = a(i)
  end do
  bm = 0_8
  m = 0_8
  do i = 1, n
    if (b(i).gt.am) then
      bm = bm + b(i)
      m = m + 1_8
    end if
  end do
  if (bm.ge.h) then
    call merge_sort(n,b(1:n))
    m = 0_8
    do i = 1, n
      m = m + 1_8
      h = h - b(i)
      if (h.le.0_8) exit
    end do
  else
    h = h - bm
    m = m + (h+am-1_8)/am
  end if
  write(*,'(i0)') m
  stop
contains
  subroutine merge_sort(n,c)
    implicit none
    integer, intent(in)       :: n
    integer(8), intent(inout) :: c(n)
    integer                   :: num, lng, i, ubnd
    num = n
    lng = 1
    do while (num.gt.1)
      do i = 1, num/2
        ubnd = min(2*i*lng,n)
        call merge(c(2*(i-1)*lng+1:(2*i-1)*lng),c((2*i-1)*lng+1:ubnd))
      end do
      lng = 2*lng
      num = (num+1)/2
    end do
    return
  end subroutine merge_sort
  subroutine merge(c1,c2)
    implicit none
    integer(8), intent(inout) :: c1(:), c2(:)
    integer(8)                :: c(size(c1)+size(c2))
    integer                   :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1)
    n2 = size(c2)
    do while (i1.le.n1.and.i2.le.n2)
      if (c1(i1).ge.c2(i2)) then
        c(i1+i2-1) = c1(i1)
        i1 = i1+1
      else
        c(i1+i2-1) = c2(i2)
        i2 = i2+1
      end if
    end do
    if (i1.le.n1) then
      c(i1+i2-1:n1+n2) = c1(i1:n1)
    else if (i2.le.n2) then
      c(i1+i2-1:n1+n2) = c2(i2:n2)
    end if
    c1 = c(1:n1)
    c2 = c(n1+1:n1+n2)
    return
  end subroutine merge
end program katana_thrower

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i, k , n) for(int i = k; i <= n; i++)
typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


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

   int a, b; cin >> a >> b;
   int ans = 0;
   REP(i, a, b)
   {
      int tmp = i;
      int res = 0;
      while(tmp)
      {
         res = res*10 + tmp%10;
         tmp /=10;
      }
      if(res== i)
         ans++;

   }
   cout << ans << nl;
   return 0;
}


Measured memory_bytes: 3660
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		string s;
		cin >> s;
		ll n = s.length();
		if (s[n - 1] == 's')
			s.pb('e'), s.pb('s');
		else
			s.pb('s');

		cout << s;
	}
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
struct edges
{
	int to,next,v;
}edge[202020];
int first[101010],now;
void adde(int x,int y,int z)
{
	now++;
	edge[now].to=y;
	edge[now].next=first[x];
	edge[now].v=z;
	first[x]=now;
}
bool vis[101010];
int c[101010];
int ap[3];
int cnt=0,cnt1=0;
bool work(int p)
{
	bool ret=true;
	vis[p]=true;
	ap[c[p]]++;
	cnt1++;
	for(int e=first[p];e;e=edge[e].next)
	{
		cnt++;
		if(!vis[edge[e].to])
		{
			c[edge[e].to]=(c[p]+edge[e].v)%3;
			if(!work(edge[e].to))
				ret=false;
		}
		else if(c[edge[e].to]!=(c[p]+edge[e].v)%3)
			ret=false;
	}
	return ret;
}
int main()
{
	int n,m,x,y;
	long long ans=0;
	scanf("%d%d",&n,&m);
	memset(first,0,sizeof(first));
	now=0;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		adde(x,y,1);
		adde(y,x,2);
	}
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			c[i]=0;
			cnt=0;
			cnt1=0;
			memset(ap,0,sizeof(ap));
			if(!work(i))
				ans+=(long long)cnt1*cnt1;
			else if(ap[1]&&ap[2])
				ans+=(long long)ap[0]*ap[1]+(long long)ap[1]*ap[2]+(long long)ap[2]*ap[0];
			else
				ans+=(cnt>>1);
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8192
n,K=map(int,input().split())
p=list(map(lambda x:int(x)-1,input().split()))
c=list(map(int,input().split()))
if K == 1:
    print(max(c));exit()
ans = -10**10
def cycle(k):
    mo=k
    clen=0
    cscore=0
    flg = True
    cmax=[-10**10]
    while (mo != k or flg):
        clen+=1
        cscore+=c[mo]
        mo = p[mo]
        cmax.append(max(cmax[-1],cscore))
        if mo == k:
            flg = False
    if cscore<0:
        return cmax[min(K-1,clen-1)],cmax
    return cscore*((K-1)//clen)+cmax[(K-1)%clen+1],cmax
for i in range(n):
    a,l=cycle(i)
    if a>ans:
        ans = a
print(ans)

Measured memory_bytes: 85236
// ※※※ 解答不能 ※※※
// (解説の再現を行えなかった)
// ABC 135解説
// https://img.atcoder.jp/abc135/editorial.pdf
// 
// 上級者の解答を勉強する.
// rickytheta氏.
// https://atcoder.jp/contests/abc135/submissions/6579087
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

char s[525252], t[1525830];

int nxt[525252];

int A[525252];

int memo[525252];
const int INF = 830252521;
int dfs(int p){
    if(memo[p]!=-1){
        return memo[p];
    }
    if(nxt[p]==-1){
        return memo[p] = 0;
    }else{
        memo[p] = INF;
        return memo[p] = dfs(nxt[p]) + 1;
    }
}

int main(){
    scanf("%s%s",t,s);
    int n = strlen(s);
    int m = strlen(t);
    s[n] = '$';
    int k = 1;
    while(k==1 || k*m < 2*n){
        REP(i,m)t[i+k*m] = t[i];
        k++;
    }
    fill(nxt,nxt+m,-1);

    // KMP
    {
        A[0] = -1;
        int j = -1;
        REP(i,n+1){
            while(j>=0 && s[i]!=s[j])j = A[j];
            j++;
            A[i+1] = j;
        }
    }
    // search
    int head = 0;
    int i = 0;
    while(head+i < k*m){
        // DEBUG(head); DEBUG(i);
        if(s[i]==t[head+i]){
            i++;
            if(i==n){
                nxt[head%m] = (head+i)%m;
                // DEBUG(head%m);
            }
        }else{
            head = head+i-A[i];
            if(i>0)i = A[i];
        }
    }

    // DEBUG(n); DEBUG(m);

    fill(memo,memo+m,-1);
    int ans = 0;
    REP(i,m){
        if(nxt[i]==-1)continue;
        int x = dfs(i);
        CHMAX(ans, x);
    }
    if(ans >= INF){
        puts("-1");
    }else{
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 16128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;
	static int[] par, dep, ch;

	static void solve() {
		int n=ir.nextInt();
		long[] dp=new long[n+1];
		dp[0]=2;
		dp[1]=1;
		for(int i=2;i<=n;i++)
			dp[i]=dp[i-1]+dp[i-2];
		out.println(dp[n]);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 23124
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	var min int
	if a < b {
		min = a
	} else {
		min = b
	}

	var nums []int
	for i := 1; i <= min; i++ {
		if a%i == 0 && b%i == 0 {
			nums = append(nums, i)
		}
	}

	sort.Sort(sort.Reverse(sort.IntSlice(nums)))
	fmt.Println(nums[k-1])
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    private static final int MOD = 1_000_000_007;

    private static int[][] X;
    private static int D;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        D = sc.nextInt();

        X = new int[N][D];

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < D; j++) {
                X[i][j] = sc.nextInt();
            }
        }


        int cnt = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i == j) break;

                if (distance(i, j)) cnt++;
            }
//            System.out.println();
        }

        System.out.println(cnt);
    }

    private static boolean distance(int i, int j) {
        double sum = 0;

        for (int k = 0; k < D; k++) {
            long x = X[i][k] - X[j][k];
            sum += x * x;
        }

        double s = Math.sqrt(sum);

        return s == Math.floor(s);
    }
}


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

using namespace std;

int n;
bool s[300010];
int le,ri;
int ans=INT_MAX;

int main()
{
	cin>>n;
	int i,j;
	string str;
	cin>>str;
	for (i=1;i<=n;i++){
		if (str[i-1]=='E')s[i]=1,ri++;
		else s[i]=0;
	}
	le=0;
	for (i=1;i<=n;i++){
		if (s[i])ri--;
		ans=min(ans,le+ri);
		if (!s[i])le++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 900
import java.util.*;
public class Main {

	static int n, m;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		String a[] = new String[n];
		String b[] = new String[m];
		String found = "No";
		for(int i = 0; i < n; i++) {
			a[i] = sc.next();
		}
		for(int i = 0; i < m; i++) {
			b[i] = sc.next();
		}
		out: for(int i = 0; i <= n - m; i++) {
			for(int j = 0; j <= n - m; j++) {
				if(equalImg(a, b, i, j)) {
					found = "Yes";
					break out;
				}
			}
		}
		System.out.println(found);
	}
	static boolean equalImg(String[] a, String[] b, int dx, int dy) {
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < m; j++) {
				if(a[i + dy].charAt(j + dx) != b[i].charAt(j)) return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
public class Tebka1Begginer2019A {
    public static void Main() {
        int A, B, C;
        string[] str = System.Console.ReadLine().Split(' ');
        A = int.Parse(str[0]);
        B = int.Parse(str[1]);
        C = int.Parse(str[2]);

        if (A < C && C < B) {
            System.Console.WriteLine("Yes");
        } else if (A > C && C > B) {
            System.Console.WriteLine("Yes");
        } else {
            System.Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        long diff = (B - A);
        if (diff % 2 == 0) {
            System.out.println(diff / 2);
        } else {
            long lefty = A - 1;
            long righty = N - B;
            long slide;
            if (lefty < righty) {
                slide = lefty;
                A -= slide;
                B -= slide + 1;
            } else {
                slide = righty;
                A += slide + 1;
                B += slide;
            }
            slide++;
            System.err.println(A + " " + B);
            diff = (B - A);
            System.err.println(diff);
            System.err.println(slide);
            System.out.println(diff / 2 + slide);
        }
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
const int Maxn = 2e5 + 10;
int a[Maxn];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    double m = 0;
    for(int i = 0; i <=n - 1; i++){
        double x;
        cin >> x;
        m += 1 / x;
    }

    cout << 1 / m <<endl;
    return 0;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = []
max_sum = [0 for _ in range(m)]
price_sum = 0
for i in range(n):
    input_list = list(map(int, input().split()))
    a.append([input_list[0], input_list[1:]])
    price_sum += input_list[0]
    for j in range(m):
        max_sum[j] += input_list[j + 1]

flag = 0
for j in range(m):
    if max_sum[j] < x:
        flag = 1
if flag:
    print(-1)
else:
    min_price = price_sum
    for pattern in range(1, 2 ** n):
        flag = 0
        now_price = price_sum
        now_sum = max_sum.copy()
        # print(bin(pattern))
        for i in range(n):
            if pattern & 1 << i:
                now_price -= a[i][0]
                for j in range(m):
                    now_sum[j] -= a[i][1][j]

        # print(now_price, now_sum)
        for j in range(m):
            if now_sum[j] < x:
                flag = 1
        if not flag and now_price < min_price:
            min_price = now_price

    print(min_price)


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

int main() {
  
  long long N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i = 0; i < N; i++) cin >> a[i];
  
  long long ans = 0;
  
  for (long long i = 0; i < N - 1; i++) {
    if (a[i] + a[i + 1] <= x) continue;
    else {
      long long k = a[i] + a[i + 1] - x;
      ans += k;
      if (k <= a[i + 1]) a[i + 1] -= k;
      else {
        a[i] -= (k - a[i + 1]);
        a[i + 1] = 0;
      }
    }
  }
        
  cout << ans << endl; 
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
const long M = 1000000007;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  long a = 0;
  long dm = 1;
  for(int i=0; i<N; i++){
    char &si = S[N-1-i];
    if(si!='?'){
      a = (a+(dm*(si-'0')))%13;
    }
    dm = (dm*10)%13;
  }
  vector<long> dp(13);
  dp[a]=1;
  dm = 1;
  for(int i=0; i<N; i++){
    auto &si = S[N-1-i];
    if(si=='?'){
      vector<long> ndp(13);
      for(int j=0; j<13; j++){
        for(int k=0; k<10; k++){
          int l = (j+(dm*k))%13;
          ndp[l] = (ndp[l]+dp[j]) % M;
        }
      }
      dp = move(ndp);
    }
    dm = (dm*10)%13;
  }
  cout << dp[5] << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    bool first =false;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==1) first=true;
    }
    if(first) cout<<"first"<<endl;
    else cout<<"second"<<endl;
}

Measured memory_bytes: 1024
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int k = 18;
int cnt[k + 1][k + 1];
int n;

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      cnt[i][j] = 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    double x;
    scanf("%lf", &x);
    long long a = (long long) (x * 1e9 + 0.1);
    int p2 = 0, p5 = 0;
    while (!(a % 2)) {
      a /= 2;
      ++p2;
    }
    while (!(a % 5)) {
      a /= 5;
      ++p5;
    }
    p2 = min(p2, k);
    p5 = min(p5, k);
    ++cnt[p2][p5];
  }
  return true;
}

void solve() {
  long long res = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      for (int ii = 0; ii <= k; ++ii) {
        for (int jj = 0; jj <= k; ++jj) {
          if (i + ii >= k && j + jj >= k) {
            res += (long long) cnt[i][j] * cnt[ii][jj];
            if (i == ii && j == jj) {
              res -= cnt[i][j];
            }
          }
        }
      }
    }
  }
  res /= 2;
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;

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

  LL N, M, C;
  cin >> N >> M >> C;
  vector<vector<PLL>> G(N);
  LL sum = 0;
  REP(i,M){
	LL u, v, c;
	cin >> u >> v >> c;
	--u;
	--v;
	G[u].EB(v,c);
	G[v].EB(u,c);
	sum += c;
  }

  LL ans = sum;
  VL d(N, INF);
  d[0] = 0;
  set<int> under;
  priority_queue<PLL,vector<PLL>,greater<PLL>> pq;
  pq.push(MP(0,0));
  while(!pq.empty()){
	PLL p = pq.top();
	pq.pop();
	if(d[p.SS] < p.FF) continue;
	if(under.count(p.SS)) continue;
	under.insert(p.SS);
	for(auto&& e: G[p.SS]){
	  LL nd = e.SS + p.FF;
	  if(d[e.FF] <= nd) continue;
	  d[e.FF] = nd;
	  pq.push(MP(nd,e.FF));
	}
	for(auto&& e: G[p.SS]){
	  if(under.count(e.FF))
		sum -= e.SS;
	}
	mini(ans, sum + p.FF * C);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 21188
#include"bits/stdc++.h"
#include<atcoder/dsu.hpp>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    int N, M;
    cin >> N >> M;
    dsu uf(N);
    rep(_, M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        uf.merge(A, B);
    }
    int group = uf.groups().size();
    cout << group - 1 << endl;
    return 0;
}


Measured memory_bytes: 8828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(); //ターン数
		int judge, t = 0, h = 0;

		for (int i = 0; i < n; i++) { //ターン数繰り返す

			String tc = sc.next();
			String hc = sc.next();

			judge = tc.compareTo(hc);
			if (judge > 0) {
				t += 3;
			} else if (judge < 0) {
				h += 3;
			} else {
				t += 1;
				h += 1;
			}

		}
		System.out.println(t + " " + h);

	}

}



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


int main(){
    string a,b;
    cin >> a >> b;
    string c = a+b;
    int d = stoi(c);

    if(pow(int(sqrt(d)),2)  == d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long N,A[2000],ans,K,mod=1e9+7,i,j,cnt,t;
main()
{
	cin>>N>>K;
	for(i=0;i<N;i++)cin>>A[i];
	for(i=0;i<N;i++){
		cnt=0,t=0;
		for(j=0;j<N;j++)if(A[i]>A[j])cnt++,t+=i<j;
		ans+=K*(K-1)/2%mod*cnt%mod+t*K%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

set<string> ans;

void dfs(int i, int n, string &now, set<char> &st) {
  if(i == n) {
    ans.insert(now);
    return;
  }
  char ma = 'a'-1;
  for(auto &e: st) {
    now.push_back(e);
    dfs(i+1, n, now, st);
    now.pop_back();
    ma = max(ma, e);
  }
  ma++;
  st.insert(ma);
  now.push_back(ma);
  dfs(i+1, n, now, st);
  st.erase(ma);
  now.pop_back();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  string s = "";
  set<char> st;
  dfs(0, n, s, st);
  for(auto &e: ans) {
    cout << e << endl;
  }

}


Measured memory_bytes: 14208