akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int v1, v2, d[10];
	int i;
	int sum;
	double ans;
	
	while (scanf("%d%*c", &d[0]) != EOF){
		sum = d[0];
		
		for (i = 1; i < 10; i++){
			scanf("%d%*c", &d[i]);
			sum += d[i];
		}
		scanf("%d%*c%d", &v1, &v2);
		
		ans = 1.00 * sum / (v1 + v2);
		ans *= v1;
		sum = 0;
		for (i = 0; i < 10; i++){
			sum += d[i];
			if (ans <= sum){
				printf("%d\n", i + 1);
				break;
			}
		}
	}
	
	return (0);
}

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

int solve(int v,int w,string s,string str)
{
  int a=w;
  if(a+w-v>=(int)s.size())
    return 0;
  for(int k=2;k<(int)str.size();k++){
    int m=str[k],n=s[a+w-v];
    if(m==n) a+=(w-v);
    else return 0;
  }
  return 1;
}

int main()
{
  int n;
  string str;
  cin >> n;
  cin >> str;
  string s[n];
  int co=0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    vector<int> v,w;
    for(int j=0;j<(int)s[i].size();j++){
      if(s[i][j]==str[0]) 
        v.push_back(j);
      else if(s[i][j]==str[1]) 
        w.push_back(j);
    }
    for(int j=0;j<(int)v.size();j++)
      for(int k=0;k<(int)w.size();k++){
        if(v[j]>=w[k]) continue;
      if(solve(v[j],w[k],s[i],str)==1){
          co++;
          goto OUT;
          }
      }
    OUT: continue;
  }
  cout << co << endl;
  return 0;
}


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

int main () {
  
  long long S, X1, Y1, X2, Y2, X3, Y3;
  cin >> S;
  
  long long num = 1000000000;
  
  long long q = S / num;
  long long r = S % num;
  
  if (r == 0) {
    X1 = num;
    Y2 = q;
  }
  
  else {
    X1 = num;
    Y2 = q + 1;
    X2 = 1;
    Y1 = num - r;
  }
  
  cout << X1 << " " << Y1 << " " << X2 << " " << Y2 << " " << X3 << " " << Y3 << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    when (readLine()!!) {
        "SUN" -> print(7)
        "MON" -> print(6)
        "TUE" -> print(5)
        "WED" -> print(4)
        "THU" -> print(3)
        "FRI" -> print(2)
        "SAT" -> print(1)
    }
}


Measured memory_bytes: 33636
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL x;
LL f(LL a, LL b){
    return a * a * a * a * a - b * b * b * b * b;
}
LL fa(LL a){
    return a * a * a * a * a;
}
int main(){
    cin >> x;
    for(int i = -1000; i < 1000; i++){
        for(int j = -1000; j < 1000; j++){
            if(f(i, j) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int max = 0; 
		int cnt = 0;
		for(i=0; i<n; i++) {
			h[i] = sc.nextInt();
			if(max <= h[i]) {cnt++; max = h[i];}
		}
		sc.close();
		sc = null;
		System.out.println(cnt);
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), sample(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sample[i] = i + 1;
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    int p, q;
    int cnt = 1;
    do {
        if (sample == a) p = cnt;
        if (sample == b) q = cnt;
        cnt++;
    } while (next_permutation(sample.begin(), sample.end()));
    cout << abs(p - q) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    int l=0;
    for(int i=0;i<3;i++){
        if(s1[i]==s2[i]) l++;
    }
    cout<<l;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "Yes";
const string NO = "No";

// 1 0 0
// AB
// AB
// AC

void solve(long long N, long long A, long long B, long long C, std::vector<std::string> s){
    vector<string> ans;
    REP(i, N) {
        if (s[i] == "AB") {
            if (A == 0 && B == 0) {
                cout << NO << endl;
                return;
            }

            if(B == 0 || (i+1 != N && s[i+1] == "BC" && A != 0)) {
                ans.PB("B");
                A--;
                B++;
            } else{
                ans.PB("A");
                B--;
                A++;
            }
        }

        if (s[i] == "AC") {
            if (A == 0 && C == 0) {
                cout << NO << endl;
                return;
            }

            if(C == 0 || (i+1 != N && s[i+1] == "BC" && A != 0)) {
                ans.PB("C");
                A--;
                C++;
            } else{
                ans.PB("A");
                C--;
                A++;
            }
        }

        if (s[i] == "BC") {
            if (B == 0 && C == 0) {
                cout << NO << endl;
                return;
            }

            if(C == 0 || (i+1 != N && s[i+1] == "AC" && B != 0)) {
                ans.PB("C");
                B--;
                C++;
            } else{
                ans.PB("B");
                C--;
                B++;
            }
        }
    }

    cout << YES << endl;
    REP(i, N) {
        cout << ans[i] << endl;
    }
}

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



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

int main(){
   string s;
  cin>>s;
 
  if(s=="SUN") cout<<7<<endl;
  if(s=="MON") cout<<6<<endl;
  if(s=="TUE") cout<<5<<endl;
  if(s=="WED") cout<<4<<endl;
  if(s=="THU") cout<<3<<endl;
  if(s=="FRI") cout<<2<<endl;
  if(s=="SAT") cout<<1<<endl;
 
  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	int n;
	cin>>n;
	if(n==1)
        printf("Hello World\n");
    else
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }







    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int f = scanner.nextInt();
        int r = scanner.nextInt();
    while (m >= 0 || f >= 0) {
            char grade = ' ';
            int mf = m + f;
            if (m < 0 || f < 0) grade = 'F';
            else if (mf >= 80) grade = 'A';
            else if (65 <= mf && mf < 80) grade = 'B';
            else if (50 <= mf && mf < 65) grade = 'C';
            else if (30 <= mf && mf < 50) {
                grade = 'D';
                if (r >= 50) grade = 'C';
            } else if (mf < 30) grade = 'F';
            System.out.println(grade);
            m = scanner.nextInt();
            f = scanner.nextInt();
            r = scanner.nextInt();
        }
    }
}


Measured memory_bytes: 26380
#include<iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <vector> 
#include <unordered_map>
using namespace std; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main()
{   
	//IOS;
	#define int long long int
	int n,m,k;
	cin>>n>>m>>k;
	
	vector<int>pref(n,0);
	vector<int>suf(m,0);
	int ans=0;
	for(int i=0;i<n;i++) {
		int x;
		cin>>x;
		if(i>=1)pref[i]+=x+pref[i-1];
		else pref[i]=x;
		if(pref[i]<=k)ans=max(ans,i+1);
		//st1.push(x);
	}
	for(int i=0;i<m;i++) {
		int x;
		cin>>x;
		if(i>=1)suf[i]+=x+suf[i-1];
		else suf[i]=x;
		if(suf[i]<=k)ans=max(ans,i+1);
		//st2.push(x);
	}
	//int ans=0;	
	for(int i=0;i<n&&pref[i]<k;i++){

		auto it=upper_bound(suf.begin(),suf.end(),k-pref[i]);
		if(it!=suf.begin()){it--;
		auto ind=it-suf.begin();
		ans=max(i+1+ind+1,ans);
		//cout<<ans<<endl;
	}
	else{
		ans=max(i+1,ans);
	}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 6420
#include<iostream>
#include<vector>
#include<set>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<double> t(n+2, 0.0), v(n+2, 0.0);
    vector<double> l(n+2, 0.0), r(n+2, 0.0);
    for(int i = 1; i <= n; i++) cin >> t[i];
    for(int i = 1; i <= n; i++) cin >> v[i];
 
    for(int i = 2; i < n+2; i++) l[i] = l[i-1] + t[i-1];
    for(int i = 1; i < n+2; i++) r[i] = r[i-1] + t[i];
 
    vector<double> sv;
    for(double x = 0; x <= r[n+1]; x += 0.5) {
        double mn = 1e9+1;
        for(int i = 0; i < n+2; i++) {
            if(x < l[i]) mn = min(mn, v[i] + (l[i] - x));
            if(l[i] <= x && x <= r[i]) mn = min(mn, v[i]);
            if(r[i] < x) mn = min(mn, v[i] + (x - r[i]));
        }
        sv.push_back(mn);
    }
 
    double ans = 0;
    for(int i = 1; i < sv.size(); i++) {
        ans += 0.25 * (sv[i] + sv[i-1]);
    }
 
    printf("%lf", ans);
 
    return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		int bitArrayA[] = new int[32];
		int bitArrayB[] = new int[32];

		for(int i = 0; a > 0; i++) {
			bitArrayA[i] = (int)(a % 2);
			a /= 2;
		}
		for(int i = 0; b > 0; i++) {
			bitArrayB[i] = (int)(b % 2);
			b /= 2;
		}

		//AND
		for(int i = 0; i < 32; i++) {
			System.out.print(bitArrayA[31 - i] * bitArrayB[31 - i]);
		}
		System.out.println();
		//OR
		for(int i = 0; i < 32; i++) {
			if(bitArrayA[31 - i] + bitArrayB[31 - i] > 0) System.out.print(1);
			else System.out.print(0);
		}
		System.out.println();
		//XOR
		for(int i = 0; i < 32; i++) {
			System.out.print((bitArrayA[31 - i] + bitArrayB[31 - i]) % 2);
		}
		System.out.println();
	}

}



Measured memory_bytes: 26432
// abc079_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<ll> L(87);
    L[0] = 2;
    L[1] = 1;
    REPN(i, 2, 87){
        L[i] = L[i-1] + L[i-2];
    }

    print(L[N]);

    return 0;
}


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

int main() {
 int N, M;
 cin >> N >> M;
 vector<int> A(M);
 int ans=N;
 for (int i; i<M; i++) {
  cin >> A.at(i);
  ans -= A.at(i);
 }
 if (ans<0) {
 ans=-1;
 }
 cout << ans << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

#define fs first
#define sc second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    double sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += 1 / a[i];
    }

    printf("%.6lf\n", 1 / sum);

    return 0;
}


Measured memory_bytes: 256
// ABC048B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	ull ans = b / x;

	if (a % x == 0) {
		ans = ans - a / x + 1;
	} else {
		ans = ans - a / x;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
const ll INF = 0x7fffffffffll;

struct Entry {
	signed long long sum:40;
	unsigned int     len:12;
	unsigned int     prev:12;
	Entry(ll s = 0, short l = 0, short p = 0) : sum(s), len(l), prev(p) { }
	bool operator<(const Entry &e) const {
		if(sum < e.sum){ return true; }
		if(sum > e.sum){ return false; }
		if(len < e.len){ return true; }
		if(len > e.len){ return false; }
		return prev < e.prev;
	}
};

Entry dp[4001][4002];
short dp_count[4001] = { 0 };
int a[4000];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	dp[0][dp_count[0]++] = Entry(-INF, 0, 0);
	for(int i = 0; i < n; ++i){
		sort(&(dp[i][0]), &(dp[i][dp_count[i]]));
		for(int j = 1; j < dp_count[i]; ++j){
			if(dp[i][j - 1].len >= dp[i][j].len){ dp[i][j] = dp[i][j - 1]; }
		}
		ll s = 0;
		for(int j = i + 1; j <= n; ++j){
			s += a[j - 1];
			Entry *it = lower_bound(
				&(dp[i][0]), &(dp[i][dp_count[i]]), Entry(s, 0, 0));
			if(it == &(dp[i][0])){ continue; }
			dp[j][dp_count[j]++] = Entry(s, (it - 1)->len + 1, j - i);
		}
	}
	Entry maximum = Entry(0, 0, 0);
	for(int i = 0; i < dp_count[n]; ++i){
		if(dp[n][i].len > maximum.len){ maximum = dp[n][i]; }
	}
	int anum = 0, p = n;
	while(maximum.prev > 0){
		p = p - maximum.prev;
		a[anum++] = p;
		for(int i = 0; i < dp_count[p]; ++i){
			if(dp[p][i].sum < maximum.sum && dp[p][i].len == maximum.len - 1){
				maximum = dp[p][i];
				break;
			}
		}
	}
	sort(a, a + anum);
	cout << anum << endl;
	for(int i = 1; i < anum; ++i){
		cout << a[i];
		if(i + 1 != anum){ cout << " "; }
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 126336
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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 namespace std;


void solve(){
  int n,m;
  cin>>n>>m;
  vector<int>k(m);
  vector<vector<int>>s(m);
  rep(i,m){
    cin>>k[i];
    s[i].resize(k[i]);
    rep(j,k[i])cin>>s[i][j];
  }
  vector<int>p(m);
  rep(i,m)cin>>p[i];
  int ans=0;
  for(int bit=0;bit<(1<<n);++bit){
    int sum=0;
    vector<bool>sw(n);
    vector<int>cnt(m);
    rep(i,n){
      if(bit&(1<<i))sw[i]=true;
    }
    rep(i,m){
      rep(j,k[i]){
        if(sw[s[i][j]-1])++cnt[i];
      }
      if(cnt[i]%2==p[i])++sum;
    }
    if(sum==m)++ans;
  }
  cout<<ans;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int n, m, i, j, k, a, b, h[N], f[N], q[N];
struct AB{
	int a, b;
} d[N*4];
int cmp(AB a, AB b){
	return a.a < b.a;
}
int main(){
	scanf("%d%d", &n, &m);
	for(i=1; i<=m; i++){
		scanf("%d%d", &a, &b);
		d[i+m].b = d[i].a = a;
		d[i+m].a = d[i].b = b;
	}
	sort(d+1, d+m*2+1, cmp);
	for(i=m*2; i>=1; i--) h[d[i].a] = i;
	f[1] = q[1] = 1;
	for(i=j=1; i<=j; i++){
		a = q[i];
		for(k=h[a]; d[k].a==a; k++){
			b = d[k].b;
			if(!f[b]){
				f[b] = a;
				q[++j] = b;
			}
		}
	}
	if(j != n) printf("No\n");
	else{
		printf("Yes\n");
		for(i=2; i<=n; i++) printf("%d\n", f[i]);
	}
	return 0;
}

Measured memory_bytes: 8112
#include <cstdio>
#include <vector>
#include <algorithm>
 
using namespace std;

const int MAXN = 100000,MAX = 200005;
int f[MAX],difx[MAX],dify[MAX];
inline int FindSet(int a)
{
	if(a == f[a]) return a;
	return f[a] = FindSet(f[a]);
}
int main()
{
    int i,n; 
	scanf("%d",&n);
	for(i = 1;i <= MAXN * 2;i++) f[i] = i;
	for(i = 1;i <= n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		f[FindSet(u)] = FindSet(v + MAXN);
	}
	for(i = 1;i <= MAXN;i++)
		difx[FindSet(i)]++;
	for(i = MAXN + 1;i <= MAXN * 2;i++)
		dify[FindSet(i)]++;
	long long ans = 0;
	for(i = 1;i <= MAXN * 2;i++)
		ans += 1ll * difx[i] * dify[i];
	printf("%lld",ans - n);
    return 0;
}

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

int main(){
  int N,x;
  cin>>N>>x;
  if(x==1 || x==2*N-1){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  vector<int>n;
  for(int i=1;i<=2*N-1;i++){
    n.push_back(i);
  }
  int k=0;
  for(int i=1;i<=N-2;i++){
    if(n.at(k) != x-1 && n.at(k) != x && n.at(k) != x+1){
      cout<<n.at(k)<<endl;
      k++;
    }
    else{
      i--;
      k++;
    }
  }
  cout<<x-1<<endl;
  cout<<x<<endl;
  cout<<x+1<<endl;
  for(int i=1;i<=N-2;i++){
    if(n.at(k) != x-1 && n.at(k) != x && n.at(k) != x+1){
      cout<<n.at(k)<<endl;
      k++;
    }
    else{
      i--;
      k++;
    }
  }
  return 0;
}


Measured memory_bytes: 4324
#include<bits/stdc++.h>
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define print0(a)           cout<<a<<"\n"
#define print1(a)           cout<<a<<' '
#define print2(a,b)         cout<<a<<" "<<b<<" ";
#define print3(a,b,c)       cout<<a<<" "<<b<<" "<<c<<" ";
#define print4(a,b,c,d)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 1e18;
vector<int> g[N];

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
       string s;
       cin>>s;
       int n=s.length()+1;
       vi a(n);
       
       FF(i,0,n-1)
       {
           if(s[i]=='<')
           {
               chmax(a[i+1],a[i]+1);
           }
       }
       BF(i,n-2,0)
       {
           if(s[i]=='>')
           {
               chmax(a[i],a[i+1]+1);
           }
       }
       cout<<accumulate(all(a),(0LL))<<endl;

       
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||
*/



Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007


int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(2000, vector<char>(2000));
  rep(i, H) {
    rep(j, W) {
      cin >> S[i][j];
    }
  }

  vvi a(2000, vi(2000, 0)), hashx(2000, vi(2000, 0));
  rep(i, H) {
    int res = 0;
    rep(j, W) {
      if (S[i][j] == '#') {
        res++;
      }
      else if (S[i][j] == '.') {
        a[i][j] = res;
        hashx[i][res]++;
      }
    }
  }

  vvi b(2000, vi(2000, 0)), hashy(2000, vi(2000, 0));
  rep(j, W) {
    int res = 0;
    rep(i, H) {
      if (S[i][j] == '#') {
        res++;
      }
      else if (S[i][j] == '.') {
        b[i][j] = res;
        hashy[res][j]++;
      }
    }
  }
  int ans = 1;
  rep(i, H) {
    rep(j, W) {
      if (S[i][j] == '.') {
        int tmp = hashx[i][a[i][j]] + hashy[b[i][j]][j] - 1;
        ans = max(tmp, ans);
      }
    }
  }
  cout << ans << endl;

}





Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i,1,n){
        ans += n/i;
        if(n % i == 0) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
/*
 * Created by Dipta Das on 27-04-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

    ll a, b, t;
    cin >> a >> b >> t;

    ll ans = (t/a) * b;

    cout << ans << endl;

    


    return 0;
}



Measured memory_bytes: 256
X,Y,A,B,C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
r.sort()
l = p[-X:] + q[-Y:]
l.sort()

for i in range(min(X+Y,C)):
  if l[i] < r[-1]:
    l[i] = r.pop()


ans = sum(l)
print(ans)

Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
long long h,w,i,j,k,b[55][55];
char a[55][55];
int main(){
	cin>>h>>w;
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cin>>a[i][j];
			if(a[i][j]=='#'){
				b[i-1][j]++;
				b[i-1][j-1]++;
				b[i-1][j+1]++;
				b[i][j-1]++;
				b[i][j+1]++;
				b[i+1][j]++;
				b[i+1][j+1]++;
				b[i+1][j-1]++;
			}
		}
	}
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			if(a[i][j]!='#'){
				cout<<b[i][j];
			}
			else cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
import math
a, b = map(int,input().split())
c = int(math.sqrt(min(a,b)) +1)
e = max(a,b)
d = min(a,b) 
def pn(x,y):
    isprime = [1 for _ in range(x+1)]
    primes = []
    y = y
    for i in range(2,x+1):
        if isprime[i]:
            s = 2*i
            primes.append(i)
            while s <= x:
                isprime[s] = 0
                s += i
            while y%i==0:
                y = y//i
    if y!=1:
        primes.append(y)
    return primes
    
def pf(x,y,primes):
    pfs = []
    for i in primes:
        fx = x%i
        fy = y%i
        if fx==0 and fy==0:
            pfs.append(i)
            
    return pfs
primes = pn(c,d)
print(len(pf(a,b,primes))+1)

Measured memory_bytes: 14000
x=int(input())
if x<=599:
  print(8)
elif x<=799:
  print(7)
elif x<=999:
  print(6)
elif x<=1199:
  print(5)
elif x<=1399:
  print(4)
elif x<=1599:
  print(3)
elif x<=1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 61776
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return
#B
def B():

    return

#C
def C():
    n = I()
    s = S()
    d = defaultdict(lambda : 0)
    alp = list("abcdefghijklmnopqrstuvwxyz")
    f = {}
    for i in range(26):
        f[alp[i]] = i+1
    for i in range(2*n):
        s[i] = f[s[i]]
    for i in range(n>>1):
        s[i],s[n-i-1] = s[n-i-1],s[i]
    k = 27
    m = 1<<n
    p = [1<<j for j in range(n)]
    for i in range(m):
        r = 0
        b = 0
        for j in range(n):
            if i&p[j]:
                r *= k
                r += s[j]
            else:
                b *= k
                b += s[j]
        d[(r,b)] += 1
    ans = 0
    for i in range(m):
        r = 0
        b = 0
        for j in range(n):
            if i&p[j]:
                r *= k
                r += s[j+n]
            else:
                b *= k
                b += s[j+n]
        ans += d[(r,b)]
    print(ans)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 114012
from sys import stdin, setrecursionlimit
from operator import itemgetter

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            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.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


N = int(input())
P = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    P[i] = (i, x, y)

edges = []
for i in (1, 2):
    P.sort(key=itemgetter(i))
    for j in range(N - 1):
        edges.append((P[j][0], P[j + 1][0], P[j + 1][i] - P[j][i]))

edges.sort(key=itemgetter(2))
uf = UnionFind(N)
ans = 0
cities = 1
for i, j, c in edges:
    if not uf.same(i, j):
        uf.union(i, j)
        ans += c
        cities += 1
        if cities == N:
            break

print(ans)


Measured memory_bytes: 46620
A,B,K=list(map(int,input().split()))
ans=[]
if A>=K:
    ans.append(A-K)
    ans.append(B)
elif A<=K and A+B>=K:
    ans.append(0)
    ans.append(B+A-K)
else:
    ans.append(0)
    ans.append(0)
print(*ans)

Measured memory_bytes: 3316
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner scan=new Scanner(System.in);
        String s= scan.nextLine();
        String ans=new String();
        if(s.equals("ABC"))
        {
            ans="ARC";
        }
        else
        ans="ABC";
        System.out.println(ans);
        
    }
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define FOR_IN(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define IN(x, a, b) ((x) >= (a) && (x) <= (b))

using namespace std;

/*
S'
T

50
UNRESTORABLE
 */

char s[51];
char t[51];

int main(){
  cin >> s;
  cin >> t;

  int ls=strlen(s);
  int lt=strlen(t);
  int match=-1;
  REP(i, ls-lt+1){
    //cerr << "i=" << i << "\n";
    bool f=true;
    REP(j, lt){
      if(s[i+j]=='?') continue;
      if(s[i+j]!=t[j]){
        //cerr << s[i+j] << " " << t[j] << "\n";
        f=false;
        break;
      }
    }
    if(f)
      match=i;
  }

  if(match<0){
    cout << "UNRESTORABLE\n";
    return 0;
  }

  char ans[51];
  REP(i,ls){
    if(IN(i, match, match+lt-1)){
      ans[i]=t[i-match];
    } else if(s[i]!='?') {
      ans[i]=s[i];
    } else {
      ans[i]='a';
    }
  }
  ans[ls]='\0';
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int h,w,n,d[10010],m,i,j,r=0;
	scanf("%d %d %d",&h,&w,&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		for(j=0;j<m;j++)d[r++]=i+1;
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++)printf("%d%c",d[i*w+(i%2?w-j-1:j)],w-j-1?' ':'\n');
	}
	return 0;
}

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

int main(void)
{
    int cnt = 0;
    string w, t;
    cin >> w;
    transform(w.begin(), w.end(), w.begin(), ::tolower);
    while(cin >> t && t != "END_OF_TEXT") {
        transform(t.begin(), t.end(), t.begin(), ::tolower);
        if (t == w)
            ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef pair<int,int> pr;

vector <int> e[2005];
int d[2005];

int fa[2005],dep[2005];

void dfs1(int x) {
  for(int i=0;i<e[x].size();i++)
    if (e[x][i]!=fa[x]) {
    	int u=e[x][i];
    	fa[u]=x;dep[u]=dep[x]+1;
    	dfs1(u);
	}
}

int lca(int x,int y) {
  if (dep[x]<dep[y]) swap(x,y);
  while (dep[x]>dep[y]) x=fa[x];
  while (x!=y) {
  	x=fa[x];
  	y=fa[y];
  }
  return x;
}

int sum[2005];

void dfs2(int x) {
  for(int i=0;i<e[x].size();i++)
    if (e[x][i]!=fa[x]) {
    	int u=e[x][i];
    	dfs2(u);
    	sum[x]+=sum[u];
	} 
}

int p[2005];
bool col[2005],vis[2005];

pr num[2005],fir[2005];

int main() {
//	freopen("testdata.in","r",stdin);
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[x].push_back(y);
  	e[y].push_back(x);
  	d[x]++;d[y]++;
  }
  dfs1(1);
  for(int i=1;i<=m;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	fir[i]=num[i]=pr(x,y);
  	sum[x]++;sum[y]++;
  	sum[lca(x,y)]-=2;
  }
  dfs2(1);
  int ans=0;
  for(int i=2;i<=n;i++) ans+=min(sum[i],2);
  printf("%d\n",ans);
  for(int i=2;i<=n;i++) {
  	int u=0;
  	for(int j=2;j<=n;j++)
  	  if (d[j]==1&&!vis[j]) {
  	  	  u=j;
  	  	  break;
		}
	vis[u]=1;
	int v=0;
	for(int j=0;j<e[u].size();j++)
	  if (!vis[e[u][j]]) {
	  	v=e[u][j];
	  	break;
	  }
	d[v]--;
	int id1=0,id2=0;
	for(int j=1;j<=m;j++)
	  if ((num[j].FR==u)^(num[j].SE==u)) {
	  	if (!id1) id1=j;
	  	else if (!id2) id2=j;
	  }
//	  printf("%d %d %d\n",i,id1,id2);
	if (!id1&&!id2) continue;
	if (!id2) {
		if (num[id1].FR==u) num[id1].FR=v;
		else num[id1].SE=v; 
		continue;
	}
	if (num[id1].FR==u) {
		if (num[id2].FR==u) {
			num[id1].FR=num[id2].SE;
			col[id2]^=1;
		}
		else num[id1].FR=num[id2].FR;
	}
	else {
		if (num[id2].SE==u) {
			num[id1].SE=num[id2].FR;
			col[id2]^=1;
		}
		else num[id1].SE=num[id2].SE;
	}
	num[id2].FR=num[id2].SE;
	p[id2]=id1;
	for(int j=1;j<=m;j++)
	  if ((num[j].FR==u)^(num[j].SE==u)) {
	  	if (num[j].FR==u) num[j].FR=v;
	  	else num[j].SE=v;
	  }
  }
  for(int i=1;i<=m;i++)
    if (p[i]) col[i]^=col[p[i]];
  for(int i=1;i<=m;i++) {
  	if (col[i]) swap(fir[i].FR,fir[i].SE);
  	printf("%d %d\n",fir[i].FR,fir[i].SE);
  }
  return 0;
}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin >> s;
    if(s=="SUN"){
            cout << "7" << endl;
    }
    else if(s=="MON"){
        cout << "6" <<endl;
    }
    else if(s=="TUE"){
        cout << "5" << endl;
    }
    else if(s=="WED"){
        cout << "4" << endl;
    }
    else if(s=="THU"){
        cout << "3" << endl;
    }
    else if(s=="FRI"){
        cout << "2" << endl;
    }
    else cout << "1" << endl;
}



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

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

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

int main(void)
{
    char S[5];
    int M,N;
    int i,j,t;

    scanf("%d",&M);
    N=M;
    j=0;
    j = j + N/1000000000;
    N=N-N/1000000000*1000000000;
    j = j + N/100000000;
    N=N-N/100000000*100000000;
    j = j + N/10000000;
    N=N-N/10000000*10000000;
    j = j + N/1000000;
    N=N-N/1000000*1000000;
    j = j + N/100000;
    N=N-N/100000*100000;
    j = j + N/10000;
    N=N-N/10000*10000;
    j = j + N/1000;
    N=N-N/1000*1000;
    j = j + N/100;
    N=N-N/100*100;
    j = j + N/10;
    N = N - N/10*10;
    j = j + N/1;

    if(M%j==0) printf("Yes\n");
    else       printf("No\n");
    return 0;
}

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

const int N = 2005;

int f[N][N], n, m, q, h[N][N], w[N][N], a[N][N];

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

Measured memory_bytes: 64640
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;
static const llong MOD = 1000000007LL;

llong dp[100005][13];

int main(void) {
  string ss;
  cin >> ss;

  int n = ss.size();

  for(int i=0;i<10;i++) {
    if(i==0) dp[0][i] = 1;
    else dp[0][i] = 0;
  }
  
  char c;
  int a;
  for(int i=0;i<n;i++) {
    c = ss[i];
    if(c=='?') a = -1;
    else a = c - '0';

    for(int j=0;j<10;j++) {
      if(a!=-1&&a!=j) continue;
      for(int mod=0;mod<13;mod++) {
        dp[i+1][(10*mod+j)%13] += dp[i][mod];
      }
    }
    for(int j=0;j<13;j++) dp[i+1][j] %= MOD;
  }

  cout<< dp[n][5] << endl;

  return (0);
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> n >> s ;
	int l = 0 ; 
	int r = 0 ;
	for(auto c :s ){
		if(c =='('){
			++ r;
		}else if( r != 0){
			--r ;
		}
		else ++l;
	}
	rep(i,l) cout <<"(";
	cout <<s;
	rep(i,r) cout <<")";
	cout << endl;
	//まろじぇさんの写経
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[200005], q[200005];
int f(int x) {
  if (p[x] == x) return x;
  return p[x] = f(p[x]);
}
int g(int x) {
  if (q[x] == x) return x;
  return q[x] = g(q[x]);
}
int main() {
  int n, k, l, x, y;
  scanf("%d %d %d", &n, &k, &l);
  for (int i = 1; i <= n; i++) {
    p[i] = q[i] = i;
  }
  for (int i = 0; i < k; i++) {
    scanf("%d %d", &x, &y);
    p[f(x)] = f(y);
  }
  for (int i = 0; i < l; i++) {
    scanf("%d %d", &x, &y);
    q[g(x)] = g(y);
  }
  map<pair<int, int>, int> mp;
  for (int i = 1; i <= n; i++) {
    mp[{f(i), g(i)}]++;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d%c", mp[{f(i), g(i)}], i == n ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 13568
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
a, b, c = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
# b = list(map(int, input().split()))

# 空白区切り文字列
# t, d = input().split()

print(max(0, c - (a - b)))


Measured memory_bytes: 4184
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;

int id[MAX_N], X[MAX_N], W[MAX_N];

bool cmp(int a, int b) {
  if (X[a] != X[b]) return X[a] < X[b];
  return W[a] > W[b];
}

int main() {
  int N, L, T;
  scanf("%d%d%d", &N, &L, &T);
  int tot = 0;
  
  for (int i = 0, num; i < N; ++i) {
    scanf("%d%d", &X[i], &W[i]);
    if (W[i] == 1) {
      num = (X[i] + T) / L;
      X[i] = (X[i] + T) % L;
    } else {
      num = (X[i] - T - L + 1) / L;
      X[i] = (X[i] - T) % L;
      if (X[i] < 0) X[i] += L;
    }
    
    id[i] = i;
    tot = (tot + num) % N;
  }

  sort(id, id + N, cmp);
  
  int i = (tot + N) % N;
  do {
    printf("%d\n", X[id[i]]);
    i = (i + 1) % N;
  } while (i != (tot + N) % N);
  
  return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=100000000;

#define cle(n) memset(n,0,sizeof(n))
#define MAXN 1005;
ll fun(ll x)
{
    ll ans=0;
    while(x)
    {
        ans++;
        x/=10;
    }
    return ans;

}

int main()
{
   ll n;
   ll a,b;
   ll maxn=10000;
   while(cin>>n)
   {
       maxn=100000;
       for(int i=1;i<900000;i++)
       {
           if(n%i) continue;
           a=i;
           b=n/i;
         ll temp=max(fun(a),fun(b));
        maxn=min(maxn,temp);
       }
       cout<<maxn<<endl;
   }

}



Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int mod = 1e9 + 7;
const int Inf = (int)2e9 + 5;
const ll  Lnf = (ll)2e18 + 5;
const int N   = 4e5 + 5;
int solve() 
{
	
	ll n;
	cin>>n;
	queue<ll>q;
	for(int i=1;i<=9;i++){
		q.push(i);
	}

	for(int i=0;i<=n;i++){
		ll x = q.front();
		q.pop();
		if(i+1==n) cout<<x<<endl;
		if(x%10!=0) q.push(10*x+ (x%10)-1);
		q.push(10*x + (x%10));
		if(x%10!=9) q.push(10*x+ (x%10)+1);
	}

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<vector<int>> data(n,vector<int>(2));
  for(int i=0;i<n;i++){
    cin>>data.at(i).at(0)>>data.at(i).at(1);
  }
  for(int i=0;i<n-2;i++){
    if(data.at(i).at(0)==data.at(i).at(1)&&
       data.at(i+1).at(0)==data.at(i+1).at(1)&&
       data.at(i+2).at(0)==data.at(i+2).at(1)){
      cout<<"Yes"<<endl;
      break;
    }
    else{
      if(i==n-3){
        cout<<"No"<<endl;
        break;
      }
      else{
      continue;
      }
    }
  }
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  long long int ans=1;
  int i,n,k;

  scanf("%d",&n);
  scanf("%d",&k);

  ans *= k;
  for(i=1;i<n;i++){
    ans = ans*(k-1);
  }
  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define INF 1000000
using namespace std;

int n, m;
int _dp[50010];
int c[30];

int dp(int cost){
	if(_dp[cost]) return _dp[cost];
	if(cost == 0) return 0;
	int min = INF;
	for(int i=0; i<m; i++){
		if(cost - c[i] >= 0){
			int temp = dp(cost - c[i]) + 1;
			if(temp < min) min = temp;
		}
	}
	_dp[cost] = min;
	return _dp[cost];
}

int main(void){
	cin >> n;
	cin >> m;
	
	for(int i=0; i<m; i++) cin >> c[i];
	
	cout << dp(n) << endl;
	
	return 0;
}


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

int N;
int A[100];

void disp(void)
{
  for (int i=0; i<N; ++i) {
    cout << A[i];
    if (i != (N-1)) {
      cout << " ";
    } else {
      cout << "\n";
    }
  }
}

int main(void)
{
  cin >> N;
  for (int i=0; i<N; ++i) {
    cin >> A[i];
  }
  int count = 0;

  for (int i=0; i<N; ++i) {
    int minj = i;
    for (int j=i; j<N; ++j) {
      if (A[j] < A[minj]) minj = j;
    }
    if (i != minj) {
      swap(A[i], A[minj]);
      count++;
    }
  }
  
  disp();
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
int num[3000],n;

int solve(int k, int v) {
	if (v == 0) {
		return 1;
	}
	if (k >= n) {
		return 0;
	}
	int res = solve(k + 1, v) || solve(k + 1, v - num[k]);
	return res;
}

int main()
{
	
	int m,n1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> num[i];
	}
	cin >> n1;
	for (int i = 0; i < n1; i++)
	{
		cin >> m;
		if (solve(0,m)) {
			cout << "yes"<<endl;
			continue;
		}
		cout << "no" << endl;
	}
	
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int n;
vector<int> a;

int main()
{
    cin >> n;
    a.resize(n);

    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    cout << a.size() << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input())
t = [0] * m
for i in range(m):
    t[i] = input()
import collections
c = collections.Counter(s)
d = collections.Counter(t)

m = -101
for i in range(n):
    m = max(m,c[s[i]]-d[s[i]])
for i in range(n):
    m = max(m,c[s[i]]-d[s[i]])
print(max(m,0))

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const string dc[4]={"R","D","L","U"};

string board[15];

int h,w,tar=0;

string dfs(int ci,int cj,int cd,string cur){
	if(int(cur.size())==tar) return cur;

	rep(d,4){
		if(d==(cd+2)%4) continue;
		board[ci][cj]='.';
		int ni=ci,nj=cj;
		
		bool ok=false;
		while(1){
			if(ni<0||h<=ni||nj<0||w<=nj) break;
			if(board[ni][nj]=='o'){
				ok=true;
				break;
			}
			ni+=dy[d],nj+=dx[d];
		}

		if(ok){
			string res=dfs(ni,nj,d,cur+dc[d]);
			if(res!="") return res;
		}

		board[ci][cj]='o';

	}
	return "";
}

int main(void){
	map<char,int> conv;
	conv['R']=0,conv['D']=1,conv['L']=2,conv['U']=3;

	cin >> h >> w;
	rep(i,h) cin >> board[i];

	int si=-1,sj=-1,sd=-1;
	rep(i,h)rep(j,w) if(board[i][j]=='o') tar++;
	rep(i,h)rep(j,w) if(board[i][j]!='.'&&board[i][j]!='o') si=i,sj=j;
	sd=conv[board[si][sj]];
	board[si][sj]='o';

	cout << dfs(si,sj,sd,"") << endl;

	return 0;
}

Measured memory_bytes: 3200