akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int n;
vector<ll> arr, ps;
vector<vector<ll>> dp;

ll solve(int x, int y){
    if(x == y) return 0;
    if(dp[x][y] != -1) return dp[x][y];
    // if(x > y) return 0;
    ll mn = LONG_LONG_MAX;
    for(int p = x + 1; p <= y; p++){
        ll l = solve(x, p-1);
        ll r = solve(p, y);
        if(x == 0){
            l += ps[y];
        }else{
            l += ps[y] - ps[x-1];
        }
        mn = min(mn, l + r);
    }
    return dp[x][y] = mn;
}

int main(){
    cin>>n;
    arr.resize(n);
    ps.resize(n, 0);
    dp.resize(405, vector<ll>(405, -1));
    ll cur = 0;
    for(int i = 0; i < n; i++){
        cin>>arr[i];
        cur += arr[i];
        ps[i] = cur;
    }
    ll res = solve(0, n-1);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1536
def main():
    n, m = map(int, input().split())
    st = [list(map(int, input().split())) for _ in range(m)]

    g = [[] for _ in range(n)]

    for s, t in st:
        s -= 1
        t -= 1
        g[s].append(t)

    deg = [len(x) for x in g]

    dp = [0] * n

    for u in range(n-1)[::-1]:
        now = 0
        for v in g[u]:
            now += dp[v]

        now /= deg[u]
        now += 1
        dp[u] = now

    ans = dp[0]

    for u in range(n-1):
        if deg[u] == 1:
            continue

        d = g[u][0]
        for v in g[u]:
            if dp[d] < dp[v]:
                d = v

        dp2 = [0] * n
        for x in range(n - 1)[::-1]:
            now = 0
            for y in g[x]:
                if x == u and y == d:
                    continue
                now += dp2[y]

            if x == u:
                now /= deg[x] - 1
            else:
                now /= deg[x]

            now += 1
            dp2[x] = now

        ans = min(ans, dp2[0])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 81240
n, k = map(int,input().split())
A = []
N = []

N = list(range(1,n+1))

for i in range(1,k+1):
    d = int(input())
    a=list(map(int,input().split()))
    A += a

ans = list(set(N)-set(A))

print(len(ans))

Measured memory_bytes: 9136
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int x = min(a,min(b,c));
    int ans = x;
    if(x == a){
      ans += min(b,c);
    }else if(x == b){
      ans += min(a,c);
    }else{
     ans += min(a,b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
program answer
  implicit none
  integer(8) :: i, N, ans, max
  integer(8), allocatable :: A(:)
  read(*,*) N
  allocate(A(n))
  read(*,*) A

  ans=0
  max=A(1)
  do i = 2, N
     if(A(i)<=max) then
        ans=ans+max-A(i)
     else
        max=A(i)
     end if
  end do

  write(*,*) ans
  deallocate(A)
  stop
 end program answer

Measured memory_bytes: 4664
n = int(input())
s = list(input())
u = ["S", "W"]
for i in range(2):
    for j in range(2):
        ans = [0] * n
        ans[0] = u[i]
        ans[1] = u[j]
        for k in range(2, n):
            if s[k - 1] == "o":
                if ans[k - 1] == "S":
                    if ans[k - 2] == "S":
                        c = 0
                    else:
                        c = 1
                else:
                    if ans[k - 2] == "S":
                        c = 1
                    else:
                        c = 0
            else:
                if ans[k - 1] == "S":
                    if ans[k - 2] == "S":
                        c = 1
                    else:
                        c = 0
                else:
                    if ans[k - 2] == "S":
                        c = 0
                    else:
                        c = 1
            ans[k] = u[c]
        m = 0
        if s[0] == "o":
            if ans[0] == "S":
                if ans[1] == ans[n - 1]:
                    m += 1
            else:
                if ans[1] != ans[n - 1]:
                    m += 1
        else:
            if ans[0] == "W":
                if ans[1] == ans[n - 1]:
                    m += 1
            else:
                if ans[1] != ans[n - 1]:
                    m += 1
        if s[n - 1] == "o":
            if ans[n - 1] == "S":
                if ans[0] == ans[n - 2]:
                    m += 1
            else:
                if ans[0] != ans[n - 2]:
                    m += 1
        else:
            if ans[n - 1] == "W":
                if ans[0] == ans[n - 2]:
                    m += 1
            else:
                if ans[0] != ans[n - 2]:
                    m += 1
        if m == 2:
            print("".join(ans))
            exit()
print(-1)

Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n;
vector <int> v;

void read() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.pb(x);
  }
}

void solve() {
  vector <int> sol;
  int sum = 0;
  for(int i = 0; i < n; ++i) {
    if (i % 2 == 0)
      sum += v[i];
    else sum -= v[i];
  }
  sol.pb(sum);
  for(int i = 1; i < n; ++i) {
    sol.pb(v[i - 1] * 2 - sol[i - 1]);
  }

  for(auto x : sol)
    cout << x << " ";
}

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

	return 0;
}


Measured memory_bytes: 2296
#include <bits/stdc++.h>
#define int long long
using namespace std;
int mod = 1000000007;
int sum[300000], dp[300000];
int solve(vector<int> v){
    int n = v.size();
    dp[n] = 1;
    for (int i=n-1; i >= 0; i--){
        sum[v[i]] += dp[i+1];
        sum[v[i]] %= mod;
        dp[i] = sum[v[i]];
    }
    return dp[0];
}
main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    vector<int> real;
    int last = v[0];
    for (int i=1; i < n; i++){
        if (v[i] == last) continue;
        real.push_back(last);
        last = v[i];
    }
    real.push_back(last);
    cout << solve(real);
}


Measured memory_bytes: 8688
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
    string s;
    cin >>s;
    string ans;
    bool sf=false;
    vector<string> ss(2,"");//top.header
   // bool ssf=false;
    int f,t;
    char c;
    int q;
    cin>> q;
    rep(i,q){
        cin>>f;
        if(f==1){
            sf=true xor sf;
          //  ssf=true xor ssf;
        }
        else{
            cin>>t>>c;
            if(sf xor t==1){
                ss[0]=c+ss[0];
            }else{
                ss[1]+=c;
            }
        }
    }
   // cout<<endl;
    //cout<<ss[0]<<endl;
    //cout<<s<<endl;
    //cout<<ss[1]<<endl;
    if(sf){
        reverse(all(s));
        reverse(all(ss[0]));
        reverse(all(ss[1]));
        ans=ss[1]+s+ss[0];
        
       // cout<<ss[1]<<s<<ss[0]<<endl;;
    }else{
        //cout << ss[0] << s << ss[1] << endl;
        ans=ss[0]+s+ss[1];
    }
    //reverse(all(ans));

    cout<<ans<<endl;
}

Measured memory_bytes: 1360
from sys import stdin, stdout

n = int(stdin.readline().rstrip())

l = list()

for i in range(n):
    s, p = [x for x in stdin.readline().rstrip().split()]
    l.append((s, int(p)*(-1), i + 1))
    
l.sort()
    
for i in range(n):
    print(l[i][2])

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

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> cn(1000005, 0);
  rep(i, n){
    cin >> A[i];
  }
  int ans = 0;
  sort(A.begin(), A.end());
  for(int x: A){
    if(cn[x] > 0){
      cn[x] = 2;
      continue;
    }
    for (int i = x; i < 1000005; i += x){
      cn[i]++;
    }
  }
  for(int x: A){
    if(cn[x] == 1)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    ll a, b, n; cin >> a >> b >> n;
    ll x;
    if(n >= b-1) x = b-1;
    else x = n;
    cout << floor(a*x/b) - a * floor(x/b) << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
using namespace std;


int main(){
  int n, m;
  int i, j, k, l;
  string s;
  cin >> n >> k;
  int a[n], b[n+1];
  vector<int> vec;

  for(i = 0; i < n; i++){
    cin >> a[i];
  }

  for(i = 0; i < n+1; i++){
    b[i] = 0;
  }

  for(i = 0; i < n; i++){
    b[a[i]]++;
  }
  for(i = 0; i < n+1; i++){
    if(b[i]>0){
      vec.push_back(b[i]);
    }
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  if(vec.size() < k){
    cout << 0 << endl;
    return 0;
  }
  for(i = 0; i < vec.size()-k; i++){
    ans += vec[i];
  }
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 2936
import copy
n,m,q=map(int,input().split())
intlist=[]
for i in range(q):
    intlist.append(list(map(int,input().split())))

alist=[]

def saiki(tn,a,tlist):
    global alist
    global m
    global n
    if tn == n:
        for i in range(a,m+1):
            tmplist=[]
            tmplist=copy.deepcopy(tlist)
            tmplist.append(i)
            alist.append(tmplist)
    else:
        for i in range(a,m+1):
            tmplist=[]
            tmplist=copy.deepcopy(tlist)
            tmplist.append(i)
            saiki(tn+1,i,tmplist)

saiki(1,1,[])

summax=0
for a in alist:
    tmpsum=0
    for ele in intlist:
        if a[ele[1]-1]-a[ele[0]-1] == ele[2]:
            tmpsum += ele[3]
    if tmpsum > summax:
        summax=tmpsum

print(summax)

Measured memory_bytes: 27856
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
struct UnionFind{
    vector<int> par;
    UnionFind(int N){
        par.resize(N);
        for(int i=0;i<N;i++){
            par[i] = i;
        }
    }
    void Union(int x,int y){
        par[Get(x)] = Get(y); 
    }
    bool Same(int x,int y){
        return Get(x) == Get(y);
    }
    int Get(int x){
        if(x != par[x]){
            par[x] = Get(par[x]);
        }
        return par[x];
    }
};
vector<tuple<long,int,int>> Edge;
pair<int,int> G[199999];
int To[100000];
long ans[100000];
int child[199999];
long cost[199999];
void Calc(){
	int N = rei();
	for(int i=0;i<N-1;i++){
		To[i] = i;
		int a = rei()-1;
		int b = rei()-1;
		long c = rel();
		Edge.push_back({c,a,b});
	}
	To[N-1] = N-1;
	sort(Edge.begin(),Edge.end());
	UnionFind U(N);
	int d = N;
	for(int i=N-2;i>=0;i--){
		G[d].first = To[U.Get(get<1>(Edge[i]))];
		G[d].second = To[U.Get(get<2>(Edge[i]))];
		U.Union(get<1>(Edge[i]),get<2>(Edge[i]));
		cost[d] = get<0>(Edge[i]);
		To[U.Get(get<1>(Edge[i]))] = d++;
	}
	stack<int> sp;
	sp.push(d-1);
	while(!sp.empty()){
		int v = sp.top();
		sp.pop();
		if(v >= d){
			v -= d;
			child[v] = 1;
			if(v >= N){
				child[v] += child[G[v].first] + child[G[v].second];
			}
		}
		else{
			sp.push(v+d);
			if(v >= N){
				sp.push(G[v].first);
				sp.push(G[v].second);
			}
		}
	}
	for(int i=0;i<d;i++){
		child[i] = (child[i]+1) / 2;
	}
	stack<pair<int,long>> sp2;
	sp2.push({d-1,0});
	while(!sp2.empty()){
		int v = sp2.top().first;
		long c = sp2.top().second;
		sp2.pop();
		if(v < N){
			ans[v] = c;
		}
		else{
			sp2.push({G[v].first,c + child[G[v].second]*cost[v]});
			sp2.push({G[v].second,c + child[G[v].first]*cost[v]});
		}
	}
	for(int i=0;i<N;i++){
		cout << ans[i] << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a,b;
	cin>>a>>b;
	if(b&1 or b<a*2 or b>a*4)
		cout<<"No";
	else
		cout<<"Yes";
	
	return 0; 	
}

Measured memory_bytes: 3636
import java.util.Scanner;

import static java.lang.Math.max;


public class Main{

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int w = scan.nextInt();
        long[] weight = new long[n + 1];
        long[] value = new long[n + 1];
        long[] dp = new long[w + 1];
        for (int i = 1; i <= n; i++) {
            weight[i] = scan.nextLong();
            value[i] = scan.nextLong();
        }

        // dp[i][j]  表示选到第i个物品时剩余j容量的最大价值
        for (long i = 1; i <= n; i++) {
            for (long j = w; j >= 0; j--) {
                if(j >= weight[(int)i]) {
                    dp[(int)j] = max(dp[(int)j], dp[(int)(j-weight[(int)i])] + value[(int)i]);
                } else {
                }
            }
        }
        System.out.println(dp[w]);
    }


}

Measured memory_bytes: 23252
#include<stdio.h>
int main()
{
     int a,b,c;
     int x,y,z;
     scanf("%d %d %d",&a,&b,&c);
     if(a<b)
     {
          if(a<c)
          {
                x=a;
                if(b<c)
                {
                      y=b;
                      z=c;
                }
                else
                {
                      y=c; 
                      z=b;
                }
          }
          else
          {
                x=c;
                y=a;
                z=b;
          }
     }
     else
     {
          if(a<c)
          {
               x=b;
               y=a;
               z=c;
          }
          else
          {
               z=a;
               if(b<c)
               {
                      x=b;
                      y=c;
               }
               else
               {
                      x=c;
                      y=b;
               }
          }
     }
     printf("%d %d %d\n",x,y,z);
     return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(){
	int x, y, val;
	scanf("%d",&x);
	scanf("%d",&y);
	
	if(x < y){
		val = x;
		x = y;
		y = val;
	}
	for(;x > y && y > 0;){
		val = x % y;
		x = y;
		y = val;
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=1e5+10;
ll a[MAXN];
int n;
ll ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<n;i++) if ((a[i]&1)&&(a[i+1])) {
		a[i]--; a[i+1]--; ans++;
	}
	for (int i=1;i<=n;i++) ans+=a[i]/2;
	printf("%lld\n",ans);
}

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

int main(){

  int N, M; cin >> N >> M;
  int P[100000], Y[100000];
  vector<int> yd[100001];
  
  for(int i = 0 ; i < M ; ++i){
    cin >> P[i] >> Y[i];
    yd[P[i]].push_back(Y[i]);
  }

  for(int i = 0 ; i < N ; ++i){
    sort(yd[i+1].begin(), yd[i+1].end());
  }

  for(int i = 0 ; i < M ; ++i){
    printf("%06d%06d\n",  P[i],  int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);
  }

}

Measured memory_bytes: 7808
import sys
input = sys.stdin.readline
 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
#このように書いておくことですぐに使える

def main():
    #mod=10**9+7  これは必要なのかわからない
    N,K=MI()
    a=N%K     #kで割ったあまり
    b=K-N%K   #kで割ったあまりがkより小さい時はKとの差を求める
    print(min(a,b))
 
main()

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

int main() {
	string n;
	int a[10];
	while (cin >> n) {
		for (int i = 0; i < 10; i++)
			a[i] = n[i] - '0';

		for (int i = 1; i <= 9; i++) {
			for (int j = 0; j < 10 - i; j++) {
				a[j] = (a[j] + a[j + 1]) % 10;
			}
		}

		cout << a[0] << endl;
	}
	return 0;
}

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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 1E5 + 10;

int n;
ll a[MAXN], up[MAXN];
vector<int> E[MAXN];

bool flag = true;

void DFS(int u, int pre){
	if (E[u].size() == !!pre){
		up[u] = a[u];
		return;
	}
	ll s = 0, val = 0;
	for (int v, i = 0; i < E[u].size(); ++i){
		if ((v = E[u][i]) == pre)
			continue;
		DFS(v, u);
		s += up[v];
		val = max(val, up[v]);
	}
	ll inner = s - a[u];
	up[u] = s - inner * 2;
	flag &= 0 <= up[u] && 0 <= inner && inner <= s - val;
//	printf("%d %lld\n", u, up[u]);
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", a + i);
	if (n == 2){
		puts(a[1] == a[2] ? "YES" : "NO");
		return 0;
	}

	for (int u, v, i = 1; i < n; ++i){
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	int rt = 1;
	for (int i = 1; i <= n; ++i)
		if (E[i].size() > 1){
			rt = i;
			break;
		}
	DFS(rt, 0);
	puts(flag && up[rt] == 0 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 13952
#include<iostream>

using namespace std;

int main() {

	int N[5] = { 0 };
	int k = 0;

	for (int i = 0; i < 5; i++) {

		cin >> N[i];

	}

	cin >> k;

	if (N[4] - N[0] <= k) {

		cout << "Yay!" << endl;

	}
	else {

		cout << ":(" << endl;

	}

	return 0;

}

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

const int STRING_LEN = 10;
const int ALPHABET = 26;

using namespace std;


int main() {
	string s;
	cin >> s;
	int len = s.length();
	vector<int> population(len);
	s += "R";
	int pos_RL;
	int pos_LR=0;
	bool isL = false;
	int cnt = 0;
	
	for (int i = 0; i <=len ; i++) {
		if (s[i] == 'L' && !isL) {
			isL = true;
			pos_RL = i;
		}

		if ((s[i] == 'R') && isL) {
			isL = false;
			int cnt = i - pos_LR;
			//cout << i << " " << pos_RL <<" " <<pos_LR<<endl;
			if ((pos_RL-pos_LR) % 2 == 0) {
				population[pos_RL] = cnt / 2 + cnt%2;
				population[pos_RL-1] = cnt / 2;
			}
			else {
				population[pos_RL] = cnt / 2;
				population[pos_RL - 1] = cnt / 2 + cnt % 2;
			}
			pos_LR = i;

		}

		
	}

	
	for (int p:population) {
		cout << p << " ";
	}
	
	

}

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

using namespace std;

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;  cin >> k;
    cout << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
const int maxn=100005;
const long long mod=1e9+7;
typedef long long LL;
char s[maxn];
LL dp[maxn][13];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=13;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
       if(s[i]!='?'){
        for(int j=0;j<13;j++){
           dp[i][(j*10+(s[i]-'0'))%13]=dp[i][(j*10+(s[i]-'0'))%13]+dp[i-1][j];
           dp[i][(j*10+(s[i]-'0'))%13]%=mod;
        }
       }
       else{
           for(int k=0;k<10;k++){
             for(int j=0;j<13;j++){
                dp[i][(j*10+k)%13]=dp[i][(j*10+k)%13]+dp[i-1][j];
                dp[i][(j*10+k)%13]%=mod;
             }
           }
       }
    }
    printf("%lld\n",dp[n][5]);
    return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,i,j,k,ans=0;
  string s;
  vector<int64_t> z(5);
  cin>>n;
  for(i=0;i<n;i++){
    cin>>s;
    if(s.at(0)=='M') z.at(0)++;
    else if(s.at(0)=='A') z.at(1)++;
    else if(s.at(0)=='R') z.at(2)++;
    else if(s.at(0)=='C') z.at(3)++;
    else if(s.at(0)=='H') z.at(4)++;
  }
  for(i=0;i<3;i++) for(j=i+1;j<4;j++)for(k=j+1;k<5;k++) ans+=z.at(i)*z.at(j)*z.at(k);
  cout<<ans<<endl;
}

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

int main()
{
    int a,b,c;
    scanf("%i %i %i",&a,&b,&c);
    if (a<b && a<c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2096
//panasonic2020_a.cpp
//Sat Mar 14 20:55:46 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

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

	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};


	cout << a[k-1]<< endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var r, g, b, n int
	fmt.Scan(&r, &g, &b, &n)

	var count = 0
	sumr := -r
	for i := 0; i <= n/r; i++ {
		sumr += r
		if sumr > n {
			break
		}
		sumrg := sumr - g
		for j := 0; j <= (n-sumr)/g; j++ {
			sumrg += g
			if sumrg > n {
				break
			}
			if (n-sumrg)%b == 0 {
				count++
			}
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;

    long long k,ans=0;
 cin>>k;

  for(int i=1;i<1000001;i++){
     ans = ans*10+7;
     ans = ans%k;
     if(ans == 0){
        cout<<i<<endl;
        return 0;
     }
  }

  cout<<"-1"<<endl;
    return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>

int main(void){
    int a,b,ans;
    scanf("%d%d",&a,&b);
    if(a == b){
        ans = a*2;
    }else if(a>b){
        ans = a*2-1;
    }else{
        ans = b*2-1;
    }
    printf("%d",ans);

}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0,1,-1,1,-1};
vector<int> dy={1,0,0,-1,1,1,-1,-1};
vector<vector<int>> a(0);
int h,w;

void dfs(int x,int y){
    a[x][y]=0;
    rep(i,8){
        int nx=x+dx[i],ny=y+dy[i];
        if(nx>=h||nx<0||ny>=w||ny<0) continue;
        if(a[nx][ny]==0) continue;
        dfs(nx,ny);
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    cin>>w>>h;
    vector<int> ans(0);
    while(h+w>0){
        int cnt=0;
        a=vector<vector<int>>(h,vector<int>(w));
        rep(i,h)rep(j,w) cin>>a[i][j];
        rep(i,h)rep(j,w){
            if(a[i][j]==1){dfs(i,j);cnt ++;}
        }
        cin>>w>>h;
        ans.emplace_back(cnt);
    }
    for(auto e:ans) cout<<e<<endl;
}


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

#define STRMAX 256

int main(void)
{
	char str[STRMAX];
	char out[STRMAX];
	int		num;
	int		num2;
	int		i;

	while (1) {
		memset(str, '\0', sizeof(str));
		scanf("%s", str);
		if (str[0] == '-') {
			break;
		}
		else {
			scanf("%d", &num);
			for (i=0; i<num; i++) {
				scanf("%d", &num2);
				memset(out, '\0', sizeof(out));
				strcpy(out, &str[num2]);
				str[num2] = '\0';
				strcat(out,str);
				memset(str, '\0', sizeof(str));
				strcpy(str,out);
			}
			printf("%s\n", str);
		}
	}
	return 0;
}



Measured memory_bytes: 2648
package main

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

func main() {
	In := readlineint()
	fmt.Println(In[0] * In[1])
}

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

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var bufreader = bufio.NewReaderSize(os.Stdin, 1e6)

func readline() string {
	a, _, _ := bufreader.ReadLine()
	return string(a)
}

func readlineint() (result []int) {
	in := strings.Split(readline(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll M,D;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll ans=0;
	cin>>M>>D;
	FOR(d1,2,10)FOR(d10,2,10){
		ll m=d1*d10;
		if(m<=M&&10*d10+d1<=D){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

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

int main(){
	double d,w,h;
	while(~scanf("%lf %lf %lf",&d,&w,&h)){
		if(d==w && w==h && h==0) break;
		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			double r;
			scanf("%lf",&r);
			if((d/2.0)*(d/2.0) + (h/2.0)*(h/2.0) < r*r
				|| (d/2.0)*(d/2.0) + (w/2.0)*(w/2.0) < r*r
				|| (w/2.0)*(w/2.0) + (h/2.0)*(h/2.0) < r*r)
			{
				cout << "OK" << endl;
			}
			else{
				cout << "NA" << endl;
			}
		}
	}
}

Measured memory_bytes: 0
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

const double EPS = 1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point{
    double x, y;
    Point(){}
    Point(double x0, double y0){
        x = x0; y = y0;
    }

    Point operator +(const Point &p){
        return Point(x + p.x, y + p.y);
    }
    Point operator -(const Point &p){
        return Point(x - p.x, y - p.y);
    }
    Point operator *(const double &a){
        return Point(a * x, a * y);
    }
    Point operator /(const double &a){
        return Point(x / a, y / a);
    }

    bool operator == (const Point &p){
        return equals(x, p.x) && equals(y, p.y);
    }

    bool operator < (const Point &p){
        return x != p.x ? x < p.x : y < p.y ;
    }

};

double norm(Point p){
    return p.x * p.x + p.y * p.y;
}

double v_abs(Point p){
    return sqrt(norm(p));
}

typedef Point Vector;

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point c0, double r0){
        c.x = c0.x;
        c.y = c0.y;
        r = r0;
    }
    Circle(double x0, double y0, double r0){
        c.x = x0;
        c.y = y0;
        r = r0;
    }
};

int N;
vector<Point> G(110);
int contains(Point p){
    bool con = false;
    for(int i = 0; i < N; i++){
        Vector a = G[i] - p, b = G[i + 1] - p; // G[(i + 1) % N]
        if(equals(cross(a, b), 0.0) && dot(a, b) < EPS) return 1;
        if(a.y > b.y) swap(a, b);
        if(b.y > EPS && a.y < EPS && cross(a, b) > EPS) con = !con;
    }
    if(con) return 2;
    else return 0;
}

int main(){
    cin >> N;
    rep(i, N) cin >> G[i].x >> G[i].y;
    G[N] = G[0]; 

    int Q;
    cin >> Q;
    rep(i, Q){
        Point p;
        cin >> p.x >> p.y;
        cout << contains(p) << endl;
    }
}


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

int main(){
  int N,Y;
  cin >> N >> Y;
  int yukichi_max = Y/10000;
  for (int i=0; i<=yukichi_max; i++){
    int ichiyo_max = (Y-10000*i)/5000;
    for (int j=0; j<=ichiyo_max; j++){
      int k = (Y-10000*i-5000*j)/1000;      
      if (i+j+k==N){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
      continue;
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int N,B[100010]={0};
void bset(int n){for(N=1;N<n;N+=2);}
void badd(int i,int n){for(;i<=N;i+=i&-i)B[i]+=n;}
int  bsum(int i){
  int s=0;
  for(;i;i-=i&-i)s+=B[i];
  return s;
}		   
int main(){
  int n,m,a,b,c;
  scanf("%d %d",&n,&m);
  bset(n);
  while(m--){
    scanf("%d %d %d",&a,&b,&c);
    a?printf("%d\n",bsum(c)-bsum(b-1)):badd(b,c);
  }    
  return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
   string s,t;cin>>s>>t;
   vector<int> a(26,0),b(26,0);
   for(char x:s)a[x-'a']++;
   for(char x:t)b[x-'a']++;
   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   if(a==b)cout<<"Yes";
   else cout<<"No";
   
}

Measured memory_bytes: 776
<?php
$n=trim(fgets(STDIN));
$i=0;
$ans=0;
while($i<$n){
  $s=str_split(trim(fgets(STDIN)));
  $c=count($s);
  if($s[0]=="B"){
    $startB[]=$i+1;
  }
  $check=array_keys($s,"A");
  foreach($check as $v){
    if($v+1==$c){
      $endA[]=$i+1;
    }elseif($s[$v+1]=="B"){
      ++$ans;
    }
  }
  ++$i;
}
if(isset($endA)&&isset($startB)){
  $ba=0;
  foreach($endA as $v){
    if(in_array($v,$startB)){
      ++$ba;
    }
  }
  $addAB=min(count($endA),count($startB));
  $rab=max(count($endA),count($startB));
  if($addAB==$ba&&$addAB==$rab){
    $ans+=$addAB-1;
  }else{
    $ans+=$addAB;
  }
}
echo $ans;

Measured memory_bytes: 4728
#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)

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;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+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);
    int n;
    cin>>n;
    vector<double> a(n);
    REP(i,0,n) cin>>a[i];

    vector< vector<double> > dp(n+1,vector<double>(n+1,0));
    dp[0][0]=1.0;

    REP(i,0,n){
        REP(j,0,n){
            dp[i+1][j] += dp[i][j]*(1.0-a[i]);
            dp[i+1][j+1] += dp[i][j]*a[i];
        }
    }
    double ans=1.0;
    REP(i,0,n/2+1) ans -= dp[n][i];
    cout<<ans<<endl;
//    REP(i,0,n+1) cout<<dp[n][i]<<" ";
    return 0;
}


Measured memory_bytes: 70784
//Don't give up too easy bhai
#pragma GCC optimize("O3")
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
 
#define forall(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vll vector<ll>
#define vld vector<ld>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << ">"<<#x << " ==> " << x << endl;
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T ll __t;cin>>__t;while(__t--)

void solve()
{
	ll n;cin>>n;
	map<ll,ll>m;
	ll a[n];forall(i,0,n) cin>>a[i],m[a[i]]++;
	ll ans = accumulate(a,a+n,0ll);
	ll q;cin>>q;
	while(q--)
	{
		ll x,y;cin>>x>>y;
		ll in = y - x;
		ll temp = m[x];
		m[x] = 0;
		m[y]+=temp;
		ans = ans +temp*in;
		cout<<ans;br;
	}
}

int main()
{
	fast;

		solve();br;


	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<char> S(N);
  for (int i=0;i<N;i++){
    cin >> S.at(i);
  }
  
  int count =N;
  for (int i=1;i<N;i++){
    if ( S.at(i) == S.at(i-1))
      count--;
  }
  
  cout << count << endl;
  }

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
    char s[7][10]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    char a[10];
    int ans;
    while(~scanf("%s",a))
    {
        for(int i=0;i<7;i++)
        {
            if(strcmp(a,s[i])==0)
            {
                ans=7-i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long N, std::vector<long long> A) {
  vector<ll> v(N, 0);
  for (auto a : A) {
    v[a - 1]++;
  }
  for (auto x : v) {
    cout << x << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N - 2 + 1);
  for (int i = 0; i < N - 2 + 1; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 6044
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;

int main()
{
	map <string, int> blue;
	map <string, int> red;
	map <string, int>::iterator iter;
	int n, m;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		blue[s]++;
	}
	cin >> m;
	for(int i = 1; i <= m; i++)
	{
		string s;
		cin >> s;
		red[s]++;
	}
	int ma = 0;
	for(iter = blue.begin(); iter != blue.end(); iter++)
	{
		ma = max(ma, iter -> second - red[iter -> first]);
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[1001][1001];
char a[1001][1001];
int dfs(int x,int y,int n,int m)
{
	if(y==m-1 && x==n){dp[x][y]=1;return 1;}
	if(y==m && x==n-1){dp[x][y]=1;return 1;}
	int ans=0;
	if(y+1<=m && a[x][y+1]=='.')
	{
		if(dp[x][y+1]==-1)
			dp[x][y+1]=dfs(x,y+1,n,m);
		ans=(ans+dp[x][y+1])%1000000007;
	}
	if(x+1<=n && a[x+1][y]=='.')
	{
		if(dp[x+1][y]==-1)
			dp[x+1][y]=dfs(x+1,y,n,m);
		ans=(ans+dp[x+1][y])%1000000007;
	}
	dp[x][y]=ans;
	return ans;
}
int main() {
	int n,m;
	cin>>n>>m;
	char x;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}
	memset(dp,-1,sizeof dp);
	dfs(0,0,n-1,m-1);
	cout<<dp[0][0];
	return 0;
}

Measured memory_bytes: 5248
import sys
sys.setrecursionlimit(100000)


class UnionFind:

    def __init__(self, N):
        self._N = N
        self._parents = [-1 for n in range(N)]
        self._size = [1 for n in range(N)]

    def is_root(self, x):
        return self._parents[x] < 0

    def size(self, x):
        assert self.is_root(x)
        return self._size[x]

    def find(self, x):
        if self.is_root(x):
            return x
        else:
            self._parents[x] = self.find(self._parents[x])
            return self._parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self._size[x] > self._size[y]:
            x, y = y, x

        self._parents[y] = x
        self._size[x] += self._size[y]
        self._size[y] = None


def solve():

    N, M, K = map(int, input().split())

    A = [0 for m in range(M)]
    B = [0 for m in range(M)]
    tree = UnionFind(N)
    for m in range(M):
        A[m], B[m] = map(int, input().split())
        tree.union(A[m]-1, B[m]-1)

    n_friends = [0 for n in range(N)]
    for m in range(M):
        root_a, root_b = tree.find(A[m]-1), tree.find(B[m]-1)
        assert root_a == root_b
        n_friends[A[m]-1] += 1
        n_friends[B[m]-1] += 1

    C = [0 for k in range(K)]
    D = [0 for k in range(K)]
    n_blocks_in_group = [0 for n in range(N)]
    for k in range(K):
        C[k], D[k] = map(int, input().split())
        root_c, root_d = tree.find(C[k]-1), tree.find(D[k]-1)
        if root_c == root_d:
            n_blocks_in_group[C[k]-1] += 1
            n_blocks_in_group[D[k]-1] += 1

    res = []
    for n in range(N):
        n_cand = tree.size(tree.find(n)) - n_friends[n] - n_blocks_in_group[n] - 1
        res.append(str(n_cand))
    print(' '.join(res))


solve()


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

int main(){
 	int A(0),a;
  	for(int i = 0 ; i < 3 ; i ++){
    	cin >> a;
      	A  += a;
    }
  	if(A > 21) cout << "bust" << endl; else cout << "win" << endl;
}

Measured memory_bytes: 256
/*
*Bismillahir Rahmanir Rahmin
* @Author: {{Syed Yasir Shahriar
{
/*//*\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\*/

//أعوذ بالله من الشيطان الرجيم
//بسم الله الرحمن الرحيم
 
/*//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\*/

/*};/* @Date:   {{create_time}}typedef int MyCustomType;
* @Last Modified by:   mrinm
* @Last Modified time: 2020-05-31 13:32:52
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define v vector<ll>
#define st stack<ll>
#define pq  priority_queue <int>
#define q queue<ll>
#define mod 1000000005
using namespace std;


int main(){
 /*    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
     ios::sync_with_stdio(0);
      cin.tie(0),cout.tie(0);
     /* ll t;
      int n;
      cin>>n;
      int c=0;
      */

      int a,b;
      cin>>a>>b;
      cout<<a*b<<endl;

     
     return 0;
}


Measured memory_bytes: 3644
using System;
using System.Collections;
using System.Collections.Generic;

class Program {
    static Graph G;

    public struct Graph {
        public HashSet<int>[] points;

        public Graph (int n) {
            points = new HashSet<int>[n];
            for (int i = 0; i < n; i++) {
                points[i] = new HashSet<int> ();
            }
        }

        public void AddLine (int a, int b) {
            points[a].Add (b);
            points[b].Add (a);
        }

        public void AddDirectionalLine (int a, int b) {
            points[a].Add (b);
        }
    }

    static void Main (string[] args) {
        string[] S = Console.ReadLine ().Split (' ');
        int N = int.Parse (S[0]);
        int M = int.Parse (S[1]);
        string[] Hstr = Console.ReadLine ().Split (' ');
        int[] Hlist = new int[N];
        for (int i = 0; i < N; i++) {
            Hlist[i] = int.Parse (Hstr[i]);
        }

        G = new Graph (N);
        for (int i = 0; i < M; i++) {
            var temp = Console.ReadLine ().Split (' ');
            int temp1 = int.Parse (temp[0]) - 1;
            int temp2 = int.Parse (temp[1]) - 1;
            if (Hlist[temp1] < Hlist[temp2]) {
                G.AddDirectionalLine (temp1, temp2);
            } else if (Hlist[temp1] > Hlist[temp2]) {
                G.AddDirectionalLine (temp2, temp1);
            } else {
                G.AddLine (temp1, temp2);
            }
        }

        int ans = 0;

        foreach (HashSet<int> pointset in G.points) {
            if (pointset.Count == 0) {
                ans++;
            }
        }

        Console.WriteLine (ans);

    }
}

Measured memory_bytes: 64760
s=input()
t=set(s)
t=list(t)
if len(t)!=2:
  print("No")
  exit(0)
c1,c2=0,0
for ss in s:
  if t[0]==ss:c1+=1
  if t[1]==ss:c2+=1

if c1==2 and c2==2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	/** MOD */
	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			if (Math.abs(n - m) > 1) {
				System.out.println(0);
			} else {
				System.out.println(factorialMod(n) * factorialMod(m) % MOD * ((n == m) ? 2L : 1L) % MOD);
			}
		}
	}

	/**
	 * @param n 入力数字
	 * @return 入力数字の階乗 mod MOD
	 */
	private static long factorialMod(int n) {
		long result = 1L;
		for (int i = 2; i <= n; i++) {
			result = result * i % MOD;
		}
		return result;
	}
}


Measured memory_bytes: 35768
n, k = [int(i) for i in input().split()]
A = [0] + [int(i) for i in input().split()]
# first study the cycle of A
cycle = [A[1]]
i = A[1]
visited = set(cycle)
while A[i] not in visited:
    cycle.append(A[i])
    visited.add(A[i])
    i = A[i]
interest_ind = cycle.index(A[i])
second_part = cycle[interest_ind:]
p = len(cycle) - interest_ind
k -= 1
if k < interest_ind:
    print(cycle[k])
else:
    k -= interest_ind
    k %= p
    print(cycle[interest_ind + k])

Measured memory_bytes: 32296
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[]a = new int[n];
        for(int i=0;i<a.length;i++){
            a[i] = sc.nextInt();
        }
        for(int i=0;i<a.length;i++){           
            System.out.print(a[a.length-1-i]);
            if(i != a.length-1)System.out.printf(" ");
        }
        System.out.printf("\n");
        sc.close();
    }
}


Measured memory_bytes: 26392
import numpy as np

n, k = map(int, input().split())
lst = list(map(int, input().split()))

def factorize(i):
    lst = []
    while i >= 1:
        if i % 2 == 1:
            lst.append(1)
        else:
            lst.append(0)
        i = i // 2
    lst.reverse()
    if len(lst) < 45:
        lst = [0] * (45 - len(lst)) + lst
    return lst

array = np.zeros((n,45))
for n, i in enumerate(lst):
    array[n] = factorize(i)

    
col_sum = array.sum(axis=0)

ans_lst = []
for i in col_sum:
    if i > n//2:
        ans_lst.append(0)
    else:
        ans_lst.append(1)
        
ans_lst

ans = 0
for n, i in enumerate(ans_lst):
    new_ans = ans + i * 2**(44-n)
    if new_ans > k:
        continue
    else:
        ans = new_ans
        
max_f = 0
for i in lst:
    max_f += ans ^ i
print(max_f)

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

using ll = long long;

int main() {
	int N, L; cin >> N >> L;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	int p = -1;
	for (int i = 0; i < N-1; i++) {
		if (a[i]+a[i+1] >= L) p = i+1;
	}
	if (p == -1) cout << "Impossible" << endl;
	else {
		cout << "Possible" << endl;
		for (int i = 1; i < p; i++) cout << i << endl;
		for (int i = N-1; i > p; i--) cout << i << endl;
		cout << p << endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int i=0; i<N-1; i++) cout << vec.at(i) << " ";
  cout << vec.at(N-1) << endl;
}

int main(){
  double N;
  double M;
  cin >> N >> M;
  vector<double> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  double a = A.at(N-M);
  double sum = 0;
  for(int i=0; i<N; i++) sum += A.at(i);
  if(a>=sum/4/M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	ll ans = 0;
	rrep (i, n) { 
		if (i % 3 == 0 || i % 5 == 0) continue;
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632