akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    string s; cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (r, g, b): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if (100 * r + 10 * g + b) % 4 == 0 { "YES" } else { "NO" };

    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())

q = ["3", "5", "7"]
ans = 0
while q:
    now = q.pop(0)
    if int(now) <= N:
        for c in ("3", "5", "7"):
            q.append(now + c)
        if len(set(now)) == 3:
            ans += 1

print(ans)


Measured memory_bytes: 7332
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int min = 1001;
		for(int i = 0; i < N; i++) {
			int c = sc.nextInt();
			int t = sc.nextInt();
			if(t <= T && c <= min) {
				min = c;
			}
		}

		if(min == 1001) {
			System.out.println("TLE");
		}else {
			System.out.println(min);
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF 1e9+7
#define LLINF 1e18
// #define int ll
using namespace std;
const int MOD = 1e9 +7;


struct UnionFind{
    int par[100010];
    int r[100010];

    UnionFind(int n){
        rep(i,n){
            par[i]=i;
            r[i]=0;
        }
    }

    int find(int x){
        if(par[x]==x)
        return x;
        else return par[x] =find(par[x]);
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(r[x] <r[y]){
            par[x] =y;
        }
        else{
            par[y] =x;
            if(r[x] ==r[y]) r[x]++;
        }
    }

    bool same(int x,int y){
        return find(x) ==find(y);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,p[100010],x[100010],y[100010],ans=0;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,n) cin>>p[i];
    rep(i,m){
        cin>>x[i]>>y[i];
        uf.unite(x[i],y[i]);
    }
    rep(i,n){
        if(uf.same(p[i],i+1)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}
const int mod = 1e9 + 7;
int getMul(int n){
    return (n*(n+1))/2;
}
int getSum(int n, int k){
    int min_sum = getMul(k-1);
    int max_sum = getMul(n) - getMul(n - k);
    return (max_sum - min_sum + 1 + mod)%mod;
}
void solve(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = k; i <= n; i++){
        ans = (ans + getSum(n, i))%mod;
    }
    ans = (ans + 1)%mod;
    cout << ans << endl;
}
signed main(){
    int t = 1;
    //cin >> t;
    while (t--){
        solve();
    }
}



Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100

int n, M[MAX][MAX] = {};
int d[MAX];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	d[s] = 0;
	for (int u; !q.empty();) {
		u = q.front(); q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0)continue;
			if (d[v] != INF)continue; //?????§?????¢?´¢???????????????????£???°???
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 /*zefo-based*/ << " " << ((d[i] == INF) ? (-1) : d[i]) << endl;
	}
}

int main() {
	cin >> n;
	memset(d, INF, sizeof(d));
	for (int i = 0, u, k; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0, v; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0); //zero-based

	return 0;
}

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

int main(){
    int d;
    cin >> d;
    switch(d){
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 25:
            cout << "Christmas" << endl;
            break;
    }
    return 0;
}

Measured memory_bytes: 256
import math
def merge(a, left, mid, right):
    global c
    n1 = mid - left
    n2 = right - mid
    l = a[left:left + n1]
    r = a[mid:mid + n2]
    l.append(10e10) #กำหนดขนาดจำนวนข้อมูล
    r.append(10e10)
    i = 0
    j = 0
    for k in range(left, right):
        c += 1
        if l[i] < r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1
    #แบ่งครึ่งข้อมูลไปเรื่อยๆจนสุด โดยถ้าจำนวนข้อมูลเป็นจำนวนคี่ ก็ให้แบ่งครึ่งด้านซ้ายมากกว่าด้านขวาเสมอ
def mergeSort(a, left, right):
    if left + 1 < right:
        mid = math.ceil((left + right) / 2)
        mergeSort(a, left, mid)
        mergeSort(a, mid, right)
    #ทำการ merge sort
        merge(a, left, mid, right)

    #รับ input
n = int(input())
a = list(map(int,input().split()))
c = 0
    #เรียก fn
mergeSort(a, 0, n)
    #แสดงผล
print(" ".join(map(str, a)))
print(c)



Measured memory_bytes: 70508
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int H = sc.nextInt();
			final int W = sc.nextInt();
			final int h = sc.nextInt();
			final int w = sc.nextInt();
			
			System.out.println(H * W - h * W - w * H + w * h);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    vector<int> v;

    rep(i, n) {
        int a;
        cin >> a;
        v.push_back(a);
    }

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

    int mid = (v[0] + 1) / 2;
    int Min_abs = INF;
    int ans;

    for (auto a : v) {
        if (a == v[0]) continue;
        if (abs(mid - a) < Min_abs) {
            Min_abs = abs(mid - a);
            ans = a;
        }
    }

    cout << v[0] << " " << ans << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

const int mod = 1e9 + 7;

typedef long long ll;

using namespace std;

int n, q;
string s;
vec<pair<int, int>> a;

void solve() {
  vec<int> m(n, 0);
  irep(i, 1, n) {
    if (s[i] == 'C' && s[i - 1] == 'A') m[i] = m[i - 1] + 1;
    else m[i] = m[i - 1];
  }
  rep(i, q) {
    cout << m[a[i].second] - m[a[i].first] << endl;
  }
}

int main() {
  cin >> n >> q;
  cin >> s;
  rep(i, q) {
    int l, r; cin >> l >> r;
    l--; r--;
    a.emplace_back(l, r);
  }
  solve();
  return 0;
}

Measured memory_bytes: 2100
#include<stdio.h>
#include<math.h>
int main()
{
    int n;
    scanf("%d", &n);
    int a[102];
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int j;
    int ans = 0;
    for (i = 0; i < n - 1; i++)
        for (j = i + 1; j < n; j++)
            if (ans < abs(a[i] - a[j]))
                ans = abs(a[i] - a[j]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;
vector<int> p = { 0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
LL dp[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int sz = p.size() - 1;
	dp[0][1] = 1;
	int n;
	cin >> n;
	for (int i = 1; i <= sz; i++)
	{
		int x = n;
		int cnt = 0;
		while (x)
		{
			x /= p[i];
			cnt += x;
		}
		for (int j = 1; j < N; j++)
		{
			for (int k = 1; k <= cnt + 1 && j * k < N; k++)
			{
				dp[i][j * k] += dp[i - 1][j];
			}
		}
	}
	cout << dp[sz][75] << endl;
	return 0;
}

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

int main()
{
    int n, m; cin>>n>>m;
    int ac=0, wa=0;
    map<int, int> v;
    while (m--) {
        int p;
        string s;
        cin>>p>>s;
        if (s=="AC") {
            if (v[p]<=0) wa-=v[p], ac++;
            v[p]=1;
        }
        else {
            if (v[p]<=0) v[p]--;
        }
    }
    cout<<ac<<' '<<wa<<endl;
}


Measured memory_bytes: 4992
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
A.reverse()

match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-N-N] * (N + 1)
dp[0] = 0

for i in range(1, N + 1):
  for j in A:
    if i >= match[j]:
      dp[i] = max(dp[i], dp[i - match[j]] + 1)

max_list = []
while N:
  for j in A:
    if N >= match[j] and dp[N] == dp[N - match[j]] + 1:
      max_list.append(j)
      N -= match[j]
      break

for j in max_list:
  print(j, end="")
print("")


Measured memory_bytes: 4208
# どうやってもN^2かかるんだが
# n^2通るじゃん...

n,x,y = map(int, input().split())
x-= 1
y -= 1

G = [[] for i in range(n)]
for i in range(n-1):
    G[i].append(i+1)
    G[i+1].append(i)
G[x].append(y)
G[y].append(x)

from collections import deque
ans = [0]*(n-1)
def dfs(i):
    q = deque()
    q.append([i, 0])
    used = [0]*n
    while q:
        cur,d = q.popleft()
        if used[cur]:
            continue
        used[cur] = 1
        if d > 0:
            ans[d-1] += 1
        for to in G[cur]:
            if used[to]:
                continue
            q.append([to, d+1])

for i in range(n):
    dfs(i)
ans = [i//2 for i in ans]
print(*ans, sep="\n")

Measured memory_bytes: 47708
n, m = map(int, input().split())

a = [0 for _ in range(n)]
b = [False for _ in range(n)]

ac_count = 0

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and not b[p-1]:
        a[p-1] += 1
    elif s == 'AC' and not b[p-1]:
        ac_count += 1
        b[p-1] = True

wa_count = 0

for i in range(n):
    if b[i] == True:
        wa_count += a[i]


print(ac_count, wa_count)


Measured memory_bytes: 50992
#include <stdio.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

void helper(vector<string>& strings)
{
    long long pairs = 0;

    unordered_map<string, long long> strFreq;

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

    for (string s : strings)
    {
        if (strFreq.find(s) == strFreq.end())
        {
            strFreq[s] = 1;
        }
        else 
        {
            pairs += strFreq[s];
            strFreq[s]++;
        }
    }

    cout << pairs << endl;
}

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

    int N;
    
    cin >> N;

    string S;

    vector<string> strings;

    for (int i = 0; i < N; i++)
    {
        cin >> S;
        sort(S.begin(), S.end());
        //cout << endl << S;
        strings.push_back(S);
    }
    
    helper(strings);

    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, K; cin >> N >> K;
	vint cnt(N);
	for (int i = 0; i < K; i++) {
		int d; cin >> d;
		for (int j = 0; j < d; j++) {
			int A; cin >> A; --A;
			cnt[A]++;
		}
	}
	cout << count(begin(cnt), end(cnt), 0) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    REP(i,k-1) cout << s[i] ;
    if(s[k-1] == 'A') cout << 'a';
    else if(s[k-1] == 'B') cout << 'b';
    else cout << 'c';
    FOR(i,k,n) cout << s[i];
    cout << endl;
}
 

Measured memory_bytes: 256
def get_first_end(n):
    n = str(n)
    return (int(n[0]), int(n[-1]))


n = int(input())
ans = 0

ans_dict = {}
for i in range(1, n+1):
    p = get_first_end(i)
    if not(p in ans_dict):
        ans_dict[p] = 0
    ans_dict[p] += 1

for i in range(1, n+1):
    p = get_first_end(i)
    reverse = (p[1], p[0])
    if reverse in ans_dict:
        ans += ans_dict[reverse]
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;

const ll N = 15;

string s[N];
ll a[N];
ll n;

int main() {
	cin >> n;

	ll t = 26 * 26, i = 1;
	while (a[i - 1] < 1e15) {
		a[i++] = (t - 26) / 25;
		t *= 26;
	}

	for (i = 1; i <= 14; i++) {
		//cout << a[i] << endl;
		if (a[i] >= n) {
			//cout << i << endl;
			break;
		}
	}

	//cout << endl;

	n = n - a[i - 1] - 1;
	for (ll j = 1; j <= i; j++) {
		s[j] = (n % 26) + 'a';
		//cout << s[j] << " " << n << endl;
		n /= 26;
	}

	for (ll j = i; j >= 1; j--) {
		cout << s[j];
	}
	cout << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int k;
	cin >> k;

	queue<ll> que;
	rep1(i, 9) que.push(i);
	while(k > 1) {
		ll i = que.front();
		que.pop();
		for(ll j = -1; j <= 1; j++) {
			ll k = i % 10 + j;
			if(k < 0 || k > 9) continue;
			que.push(i * 10 + k);
		}
		k--;
	}
	cout << que.front() << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;
const int INF = 1e18 + 13, maxN = 2e5 + 13;;
int n, ans = INF, mxy, mxx, mnx = INF, mny = INF, x[maxN], y[maxN];
int arr[maxN];

bool cmp (int i, int j) {
    if (x[i] != x[j])
	return x[i] < x[j];
    if (y[i] != y[j])
	return y[i] < y[j];
    return i < j;
}

int32_t main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
	cin >> x[i] >> y[i];
	if (y[i] < x[i])
	    swap(x[i], y[i]);
	mnx = min(mnx, x[i]);
	mxx = max(mxx, x[i]);
	mny = min(mny, y[i]);
	mxy = max(mxy, y[i]);
    }
    iota(arr, arr + n, 0);
    sort(arr, arr + n, cmp);
    int mn = INF, mx = mxx;
    for (int i = 1; i < n; i++) {
	mx = max(mx, y[arr[i - 1]]), mn = min(mn, y[arr[i - 1]]);
	ans = min(ans, (mxy - mnx) * (mx - min(x[arr[i]], mn)));
    }
    cout << min(ans, (mxx - mnx) * (mxy - mny)) << endl;
    return 0;
}


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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;

signed main(){
  int n;
  while(cin >> n, n){
    vi a(n);
    rep(i,n) cin >> a[i];

    int s = SUM(a);
    int ans = 0;
    rep(i,n){
      if(a[i]*n <= s) ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3164
#include <iostream>

int main(){
    int a, b;
    std::cin >> a >> b;

    if(a < b){
        std::cout << "a < b" << std::endl;
    }else if(a > b){
        std::cout << "a > b" << std::endl;
    }else{
        std::cout << "a == b" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, char const* argv[])
{
	int a,b,c,d; cin>>a>>b>>c>>d;
	if ((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main() {
    char a,b;
    cin >> a >> b;
    if (a == 'H' && b == 'H') cout << 'H' << endl;
    else if (a == 'D' && b == 'H' ) cout << 'D'<< endl;
    else if (a == 'H' && b == 'D') cout << 'D' << endl;
    else cout << 'H' << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
typedef long long ll;
ll n, m, x, y,z,w,h, sum= 1, ans = 0;
int main() {
    string s; cin >> s >> m;
    rep(i, s.size()) {
        if(s[i] == 'a') continue;
        x = s[i] - 'a';
        if (26 - x <= m) {
            m -= 26 - x;
            s[i] = 'a';
        }
    }m %= 26;
    char c = (s.back() + m);
    s[s.size() - 1] = c;
    cout << s << endl;
}


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

int m,n;
char c[500][500];

int rec(int x, int y){
  if( x<0 || x>=m ) return 0;
  if( y<0 || y>=n ) return 0;

  char U='^',D='~', R='>', L='<';
  char *u, *d, *r, *l;
  u=&U; d=&D; r=&R; l=&L;
  for( int i=y;i>=0;i-- ) if( c[x][i]!='.' ){ u=&c[x][i]; break; }
  for( int i=y;i<n;i++ )  if( c[x][i]!='.' ){ d=&c[x][i]; break; }
  for( int i=x;i>=0;i-- ) if( c[i][y]!='.' ){ l=&c[i][y]; break; }
  for( int i=x;i<m;i++ )  if( c[i][y]!='.' ){ r=&c[i][y]; break; }

  int ret=0;
  if( *u==*d ){
    *u=*d='.'; ret+=2;
  }else if( *u==*r ){
    *u=*r='.'; ret+=2;
  }else if( *u==*l ){
    *u=*l='.'; ret+=2;
  }
  if( *d==*r && *d!='.' ){
    *d=*r='.'; ret+=2;
  }else if( *d==*l && *d!='.' ){
    *d=*l='.'; ret+=2;
  }

  if( *r==*l && *r!='.' ){
    *r=*l='.'; ret+=2;
  }

  return ret;
}

int main(){
  cin >> m >> n;
  for( int i=0;i<m;i++ )
    for( int j=0;j<n;j++ )
      cin >> c[i][j];

  bool f=true;
  int ans=0;
  while( f ){
    f=false;
    for( int i=0;i<m;i++ )
      for( int j=0;j<n;j++ )
	if( c[i][j]=='.' ){
	  int rc = rec(i,j);
	  if( rc>0 ){
	    ans += rc; f=true;
	  }
	}
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<ll, ll>> ab(n);
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		ab[i] = make_pair(b, a);
	}
	sort(ab.begin(), ab.end());
	ll sumtime = 0;
	rep(i, n) {
		sumtime += ab[i].second;
		if (sumtime > ab[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3328
using System;

namespace ALDS1_10_A_FibonacciNumber
{
	class Program
	{
		static void Main ( string[] args )
		{
			int inputNum = int.Parse (Console.ReadLine ());

			int[] numArray = new int[inputNum + 1];
			numArray[0] = 1;
			numArray[1] = 1;

			for (int index = 2; index <= inputNum; index++)
			{
				numArray[index] = numArray[index - 1] + numArray[index - 2];
			}

			Console.WriteLine (numArray[inputNum]);
		}
	}
}

Measured memory_bytes: 9124
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for(int i=0;i<n;i++)a[i]=sc.nextInt();
    long[] sum = new long[n];
    sum[0]=a[0];
    for(int i=1;i<n;i++)sum[i]=sum[i-1]+a[i];
    long min = (long)Math.pow(10,12);
    for(int i=0;i<n;i++)min = Math.min(min,Math.abs(sum[n-1]-2*sum[i]));
    System.out.println(min);
  }
}

Measured memory_bytes: 91224
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 1111111;
int di[N];
int n;

int solve() {
    rep(i, 1, N - 1) {
        for(int j = i; j < N; j += i) {
            di[j]++;
        }
    }
    cin >> n;
    int ans = 0;
    rep(c, 1, n - 1) {
        ans += di[n - c];
    }
    cout << ans << endl;
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

vi g[100100];
int n, lvl[100100], s[100100], par[100100];
int F, S;

void dfs(int v, int p, int l) {
	par[v] = p;
	lvl[v] = l;
	s[v] = 1;
	for(int i = 0; i < g[v].sz; i++) {
		int to = g[v][i];
		if(to == p) continue;
		dfs(to, v, l + 1);
		s[v] += s[to];
	}
}

int main() {
	
	cin >> n;
	for(int i = 1, a, b; i < n; i++) {
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}	

	dfs(1, 0, 1);

	int cnt = (lvl[n] - 2 ) /2;

	int cur = n;

	S = s[n];

	for(int i = 0; i < cnt; i++) {
		S += s[par[cur]] - s[cur];
		cur = par[cur];
	}

	F = n - S;

	cerr << F << " " << S << endl;

	if(F > S) {
		cout << "Fennec\n";
	} else {
		cout << "Snuke\n";
	}


	return 0;
}

Measured memory_bytes: 14720
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func floatSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, m := iScan(), iScan()
	x := iSScan(n)
	ms := make([][]int, m)
	for _, v := range x {
		ms[v%m] = append(ms[v%m], v)
	}
	mss := make([][]int, m)
	for i, v := range ms {
		d := make(map[int]int)
		for _, w := range v {
			d[w]++
		}
		p := []int{0, 0}
		for _, w := range d {
			p[0] += w - w%2
			p[1] += w % 2
		}
		mss[i] = p
	}
	ans := 0
	for i := 1; i <= (m-1)/2; i++ {
		p, q := mss[i], mss[m-i]
		sp, sq := sum(p), sum(q)
		if sp == sq {
			ans += sp
		} else if sp > sq {
			ans += sq
			ans += (p[0] - larger((sq-p[1]), 0)) / 2
		} else {
			ans += sp
			ans += (q[0] - larger((sp-q[1]), 0)) / 2
		}
	}
	ans += len(ms[0]) / 2
	if m%2 == 0 {
		ans += len(ms[m/2]) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 16604
import math

def calc(num, list1, list2):
  s = 0
  for i in range(num):
    s += (list1[i] - list2[i]) ** 2
  d = math.sqrt(s)
  return d

N, D = map(int, input().split())
L = []
ans = 0

for i in range(N):
  L.append(list(map(int, input().split())))

for i in range(N):
  for j in range(i+1, N):
    c = calc(D, L[i], L[j])
    if c.is_integer():
      ans += 1

print(ans)

Measured memory_bytes: 9100
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.ArrayDeque;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long K = sc.nextLong();
        long ans = 0;
        if(A>=K){
            ans += K;
        }
        else{
            ans += A;
            K -= A;
            if(K>B){
                K -= B;
                ans -= K;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35756
#include <stdio.h>

int main(void) {
    int X, b, i;
    scanf("%d", &X);
    while (1) {
        b=1;
        for (i=2; i*i<=X; i++) {
            if (X%i==0) {
                b=0;
                break;
            }
        }
        if (b==1) break;
        X++;
    }
    printf("%d", X);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.text.DecimalFormat;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    scanner.close();
    
    DecimalFormat df = new DecimalFormat("0.0000000000");
    System.out.println(df.format((N % 2 == 0) ? 1.0/2 : 1.0*((N / 2) + 1) / N));
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>

using namespace std;

int main() {
	int N;
	double Reciprocal = 0;
	double ans;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		Reciprocal += (1.0 / a);
	}

	ans = 1 / Reciprocal;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

N, M = map(int, input().split())
S = input()
T = input()

lcm_num = lcm(N,M)
lN = lcm_num // N
lM = lcm_num // M
gcd_num = lN * lM

for i in range(0,lcm_num,gcd_num):
    if S[i//lN] == T[i//lM]:
        continue
    else:
        print(-1)
        exit()

print(lcm_num)


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

#define ll long long

signed main()
{
  int n,m;
  cin >> n >> m ;
  vector<int> v(m);
  for(int i=0; i<m; ++i){
    cin >> v[i];
  }
  for(int i=0; i<m; ++i){
    n -= v[i];
  }
  cout << ((n<0)? -1:n) << "\n";
}

Measured memory_bytes: 3660
#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>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    REP(i, H) cin >> S[i];

    vector<vector<int>> M(H, vector<int>(W, -1));

    queue<P> q;
    M[0][0] = 1; 
    q.push(P(0, 0));
    while(q.size() > 0){
        P tmp = q.front();
        if (tmp.first < H - 1 && S[tmp.first + 1][tmp.second] == '.' && M[tmp.first + 1][tmp.second] < 0){
            M[tmp.first + 1][tmp.second] = M[tmp.first][tmp.second] + 1;
            q.push(P(tmp.first + 1, tmp.second));
        }

        if (tmp.second < W - 1 && S[tmp.first][tmp.second + 1] == '.' && M[tmp.first][tmp.second + 1] < 0){
            M[tmp.first][tmp.second + 1] = M[tmp.first][tmp.second] + 1;
            q.push(P(tmp.first, tmp.second + 1));
        }

        if (tmp.first > 0 && S[tmp.first - 1][tmp.second] == '.' && M[tmp.first - 1][tmp.second] < 0){
            M[tmp.first - 1][tmp.second] = M[tmp.first][tmp.second] + 1;
            q.push(P(tmp.first - 1, tmp.second));
        }

        if (tmp.second > 0 && S[tmp.first][tmp.second - 1] == '.' && M[tmp.first][tmp.second - 1] < 0){
            M[tmp.first][tmp.second - 1] = M[tmp.first][tmp.second] + 1;
            q.push(P(tmp.first, tmp.second - 1));
        }

        q.pop();
        //if (tmp.first == H - 2 && tmp.second == W - 1) break;
        //if (tmp.first == H - 1 && tmp.second == W - 2) break;
    }

    if (M[H-1][W-1] < 0){
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    REP(i, H) REP(j, W) if (S[i][j] == '.') cnt++;
    int ans = cnt - M[H-1][W-1];

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<strstream>
#include<math.h>
using namespace std;
int main()
{
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  a=fabs(a-x);
  b=fabs(b-x);
  if(a>b)
  printf("B\n");
  else
  printf("A\n");
}

Measured memory_bytes: 128
n = int(input())
st = {}
sv = {}
for i in range(n):
	tmp = "".join(sorted(input()))
	if tmp in st.keys():
		sv[tmp] += st[tmp]
		st[tmp] += 1
	else:
		st[tmp] = 1
		sv[tmp] = 0


print(sum(sv.values()))

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

#define DEBUG_MSG_off

string S,T;
vector<string> pat(4);

const int MAX_N = 10e5;

#if 0
int rec(int index, int length) {
  if (length >= 5) {
    rec
  }

  return 
}
#endif


// @return : index -1:no_hit, 0.. hit next index
string findDream(const vector<string>& pat,
              int   cur_index,
              int   nokori) {
  if (nokori==0) return "YES";
  if (nokori<5) return "NO";
  for (int i=0; i<4; i++) {
    bool hit = true;
    int pat_length = pat[i].length();
    for (int j=0; j<pat_length; j++) {
      if (S[cur_index+j]!=pat[i][j]) {
        hit = false;
        break;
      }
    }
#ifdef DEBUG_MSG
    cerr << "hit=" << hit
      << ",cur_index=" << cur_index
      << ",nokori=" << nokori
      << ",i=" << i
      << ",pat=" << pat[i]
      << "\n";
      ;
#endif
    if (hit) {
      string ret =
        findDream(pat,
            cur_index+pat_length,
            nokori-pat_length);
      if (ret=="YES") return ret;
    }
  }
  return "NO";
}

int main() {
  cin >> S;

  pat[0] = "dream";
  pat[1] = "dreamer";
  pat[2] = "erase";
  pat[3] = "eraser";
#ifdef DEBUG_MSG
  cerr << "\n";
#endif
#if 1
  cout << findDream(pat, 0, S.length()) << "\n";
#endif

#ifdef DEBUG_MSG
  cerr << MAX_N << "\n";
  cerr << S << "\n";
#endif
  return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n,m,f[100000],sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>f[i];
	} 
	sort(f,f+n+1,cmp);
	for(int i=0;i<m;i++){
		sum+=f[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
from copy import copy

MOD = 10**9 + 7
s = input()
count = [0 for _ in range(13)]
count[0] = 1
for i in range(len(s)):
    new = [0 for _ in range(13)]
    for m in range(13):
        new[(m * 10) % 13] = count[m]
    count = new
    if s[i] != "?":
        div = int(s[i])
        count = count[-div:] +  count[:-div]
    else:
        new = [0 for _ in range(13)]
        pre = sum(count[:3])
        SUM = sum(count) % MOD
        for j in range(13):
            pre += count[(j+3) % 13]
            pre -= count[j % 13]
            new[j] = (SUM - pre) % MOD
        count = new
print(count[5])

Measured memory_bytes: 75388
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
ans = []
for _ in range(n):
    a = int(input())
    b = int(input())
    s = a+b
    if s > 10**80-1:
        ans.append("overflow")
    else:
        ans.append(str(s))
print("\n".join(ans))



Measured memory_bytes: 5600
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			long sum = 0;
			for(int i = 0;i < n;i++){
				int size = scan.nextInt() + scan.nextInt() + scan.nextInt();
				int weight = scan.nextInt();
				if(size <= 60 && weight <= 2){
					sum += 600;
				}else if(size <= 80 && weight <= 5){
					sum += 800;
				}else if(size <= 100 && weight <= 10){
					sum += 1000;
				}else if(size <= 120 && weight <= 15){
					sum += 1200;
				}else if(size <= 140 && weight <= 20){
					sum += 1400;
				}else if(size <= 160 && weight <= 25){
					sum += 1600;
				}
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 56560
//======================================
//author @Amit Singh : global_const
//======================================

#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define yeah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define loop(i,n) for(int i=0;i<n;++i)

signed main()
{ yeah;
  long double  a,b;
  cin>>a>>b;
  cout<<(long long)floor(a*b)<<endl;
  return 0;
}

Measured memory_bytes: 3808
#include<iostream>

#include<string>
#include <algorithm> 
using namespace std;

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

    // 境界を探索
    int c_b =0,c_w=0;

    for(int i = 0 ; i < n ; i++){
        string t = s.substr(i,1);
        if(t==".") c_w++;
    }

    int min = c_w;
    for(int i = 0 ; i < n ; i++){
        string t = s.substr(i,1);
        if(t=="#") c_b++;
        if(t==".") c_w--;
        if(min > c_b + c_w) min = c_b + c_w;
    }

    cout << min << endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int d[100005];
int dfs(int x) {
	if (d[x] > 0) return d[x];
	d[x] = 0;
	for (int y : g[x]) {
		d[x] = max(d[x], dfs(y) + 1);
	}
	return d[x];
}
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		g[--x].push_back(--y);
	}
	fill(d, d + n, -1);
	for (int i = 0; i < n; i++) {
		if (d[i] < 0) {
			d[i] = dfs(i);
		}
	}
	cout << *max_element(d, d + n) << endl;
	return 0;	
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s[s.size()-1]=='s'){
        cout << s;
        cout << "es" << endl;
    }
    else
    {
        cout << s;
        cout << "s" <<endl;
    }
    
}

Measured memory_bytes: 3632
s = gets.chomp
b,e = 0,s.size-1
ans = 0
while b <= e
  if s[b] == s[e]
    b += 1
    e -= 1
  elsif s[b] == "x"
    b += 1
    ans += 1
  elsif s[e] == "x"
    e -= 1
    ans += 1
  else
    ans = -1
    break
  end
end
puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007;
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	if( s[2] == s[3] && s[4] == s[5] ){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
	
#階乗#
lim = 50  #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod


	
N, P = MAP()
A = LIST()

a = [x%2 for x in A]
cnt_0 = a.count(0)
cnt_1 = a.count(1)

ans = 0

for i in range(P%2, cnt_1+1, 2):
	ans += C(cnt_1, i)

ans *= pow(2, cnt_0)
print(ans)

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

using namespace std;

bool IsPrime(long long int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (long long int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    unsigned long long int N;
    unsigned long long int ans = pow(10, 12);
    cin >> N;

    // if(IsPrime(N)){
    //     cout << N - 1 << endl;
    // }
    // else{
    for(unsigned long long int i = 1; i * i <= N; i++){
        if(N % i == 0){
            if(ans > i + N / i - 2){
                ans = i + N / i - 2;
            }
        }
    }
// }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

#include <iostream>
using namespace std;

int main(void) {
    int d;
    cin >> d;
    if(d == 25){
        cout << "Christmas" << endl;
    }else if(d == 24){
        cout << "Christmas Eve" << endl;
    }else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve Eve" << endl;
        
    }
    }


Measured memory_bytes: 256