akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <queue>

using namespace std;
#define int long long
#define double long double
#define fst first
#define snd second
#define fr(s,n,i) for(int i=s;i<n;i++)
#define fr_(s,n,i) for(int i=s;i>=n;i--)
#define srt(v) sort(v.begin(), v.end());
#define rev(v) reverse(v.begin(), v.end());
#define upr(v, aim, ind) int ind; ind=(int)distance(v.begin(), upper_bound(v.begin(),v.end(), aim));
#define sz(v) (int)v.size()
#define ers(v, i) v.erase(v.begin() + i)
#define last(v) v[sz(v) - 1]
#define swp(v, i, j) int buf = v[j]; v[j] = v[i]; v[i] = buf;
#define shout(a) cout << a << endl;
#define dshout(a) printf("%.16Lf\n", a);
#define pr pair<int, int>
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vd vector<double>
#define vdd vector<vd>
#define mx(a, b) a = max(a, b);
#define mn(a, b) a = min(a, b);
#define mulM(a,b,c) a = a * b % c;
#define squM(a,b) a = a * a % b;
#define mpr(a,b) make_pair(a,b);
#define iinp(a) int a; cin >> a;
#define sinp(a) string a; cin >> a;
#define dinp(a) double a; cin >> a;
#define ios() ios_base::sync_with_stdio(0);cin.tie(0);

int MOD = 1000000007;

int powM(int base, int exp){
    int ret = 1;
    int buf = base;
    while(exp > 0){
        if(exp & 1){
            ret *= buf;
        }
        squM(buf, MOD)
        exp >>= 1;
    }
    return ret;
}
int combM(int a, int b){
    if(b == 0){
        return 1;
    }
    if(a-b < b){
        return combM(a, a-b);
    }
    int ans = 1;
    fr(1,b+1,i){
        ans *= a + 1 - i;
        ans /= i;
    }
    return ans;
}
void solve();
signed main() {
    ios()
    solve();
    return 0;
}






void solve(){
  iinp(N)iinp(M)
  vp bridges(M);
  vi connected;
  connected.push_back(0);
  fr(0,M,i){
    iinp(a)iinp(b)
    bridges.emplace_back(a,b);
  }
  rev(bridges)
  map<int, int> ch;
  map<int, int> par;
  set<int> found;
  int con = 0;
  fr(0,M,i){
    int a = bridges[i].fst;
    int b = bridges[i].snd;
    int pa = par[a];
    int pb = par[b];
    vi pars;
    while(pa != 0 && par[pa] != pa){
      pars.emplace_back(pa);
      pa = par[pa];
    }
    for(int p:pars){
      par[p] = pa;
    }
    pars.clear();
    while(pb != 0 && par[pb] != pb){
      pars.emplace_back(pb);
      pb = par[pb];
    }
    for(int p:pars){
      par[p] = pb;
    }
// printf("%lld,%lld,",pa,pb);
    if(pa == 0 && pb == 0){
      par[b]=a;
      par[a]=a;
      ch[a] = 2;
      con++;
    } else if(pa == pb){
      connected.emplace_back(con);
      continue;
    } else if(pb == 0) {
      par[b] = pa;
      con+=ch[pa];
      ch[pa]++;
    } else if(pa == 0){
      par[a] = pb;
      con+=ch[pb];
      ch[pb]++;
    } else {
      con-=ch[pa]*(ch[pa]-1)/2;
      con-=ch[pb]*(ch[pb]-1)/2;
      ch[pa] += ch[pb];
      con+=ch[pa]*(ch[pa]-1)/2;
      par[pb] = pa;
      par[b] = pa;
      ch[pb] = 0;
    }
// shout(f);
// shout(ch[f]);
// shout(con);
    connected.emplace_back(con);
  }
  rev(connected);
  int m = N*(N-1)/2;
  fr(1,M+1,i){
    shout(m-connected[i])
  }
}



Measured memory_bytes: 13540
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

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

  cout << n*n*n << endl;
}


Measured memory_bytes: 3624
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var x, y string

	if sc.Scan() {
		x = sc.Text()
	}
	if sc.Scan() {
		y = sc.Text()
	}

	if x < y {
		fmt.Println("<")
	} else if x > y {
		fmt.Println(">")
	} else {
		fmt.Println("=")
	}
}

Measured memory_bytes: 640
n, a, b = map(int, input().split())
mod = 10**9+7
ans = pow(2, n, mod)-1

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


print((ans-combination(n, a)-combination(n, b))%mod)

Measured memory_bytes: 40364
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer[] A = new Integer[N];
        Integer[] B = new Integer[N];

        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(sc.next());
            B[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(A);
        Arrays.sort(B, Collections.reverseOrder());

        PrintWriter out = new PrintWriter(System.out);
        out.println(A[N - 1] + B[N - 1]);
        sc.close();
        out.flush();
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define rep(i, a, b) for(int i=int(a); i<int(b); i++)

int32_t main()
{
    clock_t tStart = clock();
    IOS;

    int n;
    cin >> n; 

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

    vector<vector<int>> dp(n, vector<int>(3, INT_MIN));

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i=1; i<n; i++){

        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);

        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);

        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);

    }
    
    int res = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

    cout << res << endl;


    // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 11140
s = input()
t = input()
l = len(t)

if len(s)<l:
    print('UNRESTORABLE')   
    exit() 
for i in range(len(s),-1+l,-1):
    tmp = s[i-l:i]
    tmp_flag = False
    for j in range(l):
        if tmp[j]=='?':
            tmp_flag = True
        elif tmp[j]!=t[j]:
            tmp_flag = False
            break
        else:
            tmp_flag = True
    if tmp_flag:
        t = list(t)
        s = list(s)
        s[i-l:i] = t
        break

if tmp_flag:
    for i in range(len(s)):
        if s[i]=='?':
            s[i] = 'a'
    print(''.join(s))
else:
    print('UNRESTORABLE')


Measured memory_bytes: 9032
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int fiveHundred = Integer.parseInt(scanner.nextLine());
        int hundred = Integer.parseInt(scanner.nextLine());
        int fifty = Integer.parseInt(scanner.nextLine());
        int money = Integer.parseInt(scanner.nextLine());

        if (money % 100 == 50) {
            if (fifty == 0) {
                System.out.println(0);
                System.exit(0);
            }
            fifty -= 1;
            money -= 50;
        }

        int total = 0;
        if (money >= 500) {
            for (int i = Math.min(fiveHundred, Math.floorDiv(money, 500)); i >= 0; i--) {
                total += countUp(money - (500 * i), hundred, fifty);
            }
        } else {
            total = countUp(money, hundred, fifty);
        }
        System.out.println(total);
    }

    public static int countUp(int sum, int hundred, int fifty) {
        int c = 0;
        for (int i = Math.min(hundred, sum / 100); i >= 0; i--) {
            if ((sum - (i * 100)) <= (fifty * 50)) {
                c++;
            }
        }
        return c;
    }
}

Measured memory_bytes: 24148
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

double dot(P x,P y){return real(conj(x)*y);}

double cross(P x,P y){return imag(conj(x)*y);}

//for line(segment)
int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//for polygon

//all vertex is already sorted.
double area(Poly p){
  if(p.size()<3)return 0;
  double res = cross(p[p.size()-1],p[0]);
  for(int i=1;i<p.size();i++)res += cross(p[i-1],p[i]);
  return res/2;
}

//all vertex is already sorted.
Poly convex_cut(Poly p,L l){
  Poly res;
  int n = p.size();
  for(int i=0;i<n;i++){
    int nxt = (i+1)%n;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

int main(){
  int n,m;
  int bx,by,dx,dy,s;
  P p[110];
  Poly vor[110];
  const int lim = 30000;
  double ans[110];

  while(cin >> n >> m,n+m){
    FOR(i,0,n)cin >> p[i].real() >> p[i].imag();
    
    FOR(i,0,n){
      ans[i] = 0.0;

      vor[i].resize(4);
      vor[i][0] = P(-lim,-lim); vor[i][1] = P(lim,-lim);
      vor[i][2] = P(lim,lim); vor[i][3] = P(-lim,lim);

      FOR(j,0,n){
	if(i!=j){
	  P nor = (p[i]-p[j]) * P(0,-1);
	  P mid = (p[i]+p[j])/2.0;
	  vor[i] = convex_cut(vor[i],L(mid,mid+nor));
	}
      }
    }
    FOR(i,0,m){
      cin >> bx >> by >> dx >> dy >> s;
      double rect = 4*dx*dy;
      Poly cut(4);
      cut[0] = P(bx-dx,by-dy); cut[1] = P(bx+dx,by-dy);
      cut[2] = P(bx+dx,by+dy); cut[3] = P(bx-dx,by+dy);
	
      FOR(j,0,n){
	Poly tmp = vor[j];
	FOR(k,0,4){
	  tmp = convex_cut(tmp,L(cut[k],cut[(k+1)%4]));

	}
	ans[j] += area(tmp)/rect*s;
      }
    }
    double res = 0.0;
    FOR(i,0,n)res = max(res,ans[i]);
    cout.setf(ios::fixed); cout.precision(9);
    cout << res << endl;
  }
}

Measured memory_bytes: 1336
#include <stdio.h>
int main (){
    long long int N; 
    long long int total=1;
    
    scanf("%lld",&N);
    long long int A[N]; 
    
    for(int i=0;i<N;i++){
        scanf("%lld", &A[i]);
    }
    for(int r=0;r<N;r++){
        if(A[r] == 0){  
            printf("0"); 
            return 0;
        }
    }
    for(int k=0;k<N;k++){
        if(A[k]<=1000000000000000000/total){
            total = total*A[k];
       
        } else {
            printf("-1");
            return 0;
        }
    }
    printf("%lld", total);
    
    
return 0;
}

Measured memory_bytes: 2508
package main

import (
	"fmt"
	"sort"
)

func main() {
	a := make([]int, 2)
	for i := 0; i < 2; i++ {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)

	var f bool
	f = true

	for i := 0; i < 2; i++ {
		if a[i] != i+1 {
			fmt.Println(i + 1)
			f = false
			break
		}
	}

	if f {
		fmt.Println(3)
	}

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
//#define coutyn(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m; cin >> n >> m;
    Graph g(n + 1);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n + 1, -1);
    vector<int> pre(n + 1, -1);
    dist[0] = 0;
    q.push(1);
    while(!q.empty())
    {
        int v = q.front();q.pop();
        for(auto it : g[v])
        {
            if (dist[it] != -1) continue;
            dist[it] = dist[v] + 1;
            pre[it] = v;
            q.push(it);
        }
    }

    cout << "Yes" << endl;
    Rep(i, 2, n + 1)
    {
        int ans = pre[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 10568
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long Q = inputArray[1];

			var hens = createLongTuppleList(N-1);
			var nums = createLongTuppleList(Q);

			var countDic = new Dictionary<long, long>();
			
			for (int i = 1; i <= N; i++) {
				countDic.Add(i, 0);
			}
			
			for (int i = 0; i < Q; i++) {
				var num = nums[i];
				countDic[num.Item1] += num.Item2;
			}


			//treeの構造を作成する
			_tree = new Dictionary<long, List<long>>();
			for (int i = 1; i <= N; i++) {
				_tree.Add(i, new List<long>());
			}
			for (int i = 0; i < N-1; i++) {
				var hen = hens[i];
				_tree[hen.Item1].Add(hen.Item2);
				_tree[hen.Item2].Add(hen.Item1);
			}
			
			_ansDic = new Dictionary<long, long>();
			for (int i = 1; i <= N; i++) {
				_ansDic.Add(i, 0);
			}

			_countDic = countDic;
			DFS(1,0,-1);

			for (int i = 1; i <= N; i++) {
				Console.WriteLine(_ansDic[i]);
			}

			//答えの出力
			var ans = "";
			Console.WriteLine(ans);

		}

		private static Dictionary<long, long> _ansDic;
		private static Dictionary<long, List<long>> _tree;
		private static Dictionary<long, long> _countDic;



		/// <summary>
		/// DFS
		/// </summary>
		/// <param name="position"></param>
		/// <param name="fromNum"></param>
		/// <param name="from"></param>
		private static void DFS(long position , long fromNum, long from) {

			var num = fromNum + _countDic[position];
			_ansDic[position] = num;

			var nexts = _tree[position];

			foreach (var next in nexts) {
				if (next != from) {
					DFS(next, num, position);
				}
			}

		}


		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 122620
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;


int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    vi h(n);
    rep(i,n) cin >> h.at(i);
    int64_t a,b;
    vector<pair<int64_t, int64_t>> pv;
    rep(i,m){
        cin >> a >> b;
        pv.push_back(make_pair(a,b));
        pv.push_back(make_pair(b,a));
    }
    sort(pv.begin(), pv.end());
    int64_t index = 1;
    vi res(n,1);
    rep(i,pv.size()){
        int64_t targetHeight = h.at(pv.at(i).first-1);
        int64_t compareHeight = h.at(pv.at(i).second-1);
        if(targetHeight <= compareHeight){
            res.at(pv.at(i).first-1) = 0;
        }
    }
    int64_t result = 0;
    rep(i,n) result += res.at(i);
    cout << result << endl;
}

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

using namespace std;

const int N = 2e5 + 5;
const long long MOD = 1e9 + 7;

long long fact[N];

long long power (long long x, long long y) {
	long long res = 1;
	while (y > 0) {
		if (y & 1LL) {
			res = 1LL * (res * x) % MOD;
		}
		y >>= 1LL;
		x = 1LL * (x * x) % MOD;
	}
	return res;
}

long long di (long long x, long long y) {
	return x * power(y, MOD - 2) % MOD;
}

long long calc (int x0, int y0, int x, int y) {
	int sum = x + y - x0 - y0;
	long long div1 = di(fact[sum], fact[x - x0]);
	div1 = di(div1, fact[y - y0]);
	return div1;
}

int main() {
	int h, w, a, b;
	scanf("%d %d %d %d", &h, &w, &a, &b);
	fact[0] = 1;
	for (int i = 1; i < N; ++i) {
		fact[i] = fact[i - 1] * 1LL * i % MOD;
	}
	long long ret = 0;
	for (int i = 1; i <= h - a; ++i) {
		long long ans1 = calc(1, 1, i, b);
		long long ans2 = calc(i, b + 1, h, w);
		ret += 1LL * ans1 * ans2 % MOD;
		ret %= MOD;
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 1LL<<60;
/* -- template -- */

int main(){
    int N; cin >> N;
    map<string, ll> m;
    string s;
    rep(i, N){
        cin >> s;
        sort(s.begin(), s.end());
        m[s] += 1;
    }
    auto begin = m.begin(), end = m.end();
    ll ans = 0;
    for(auto iter = begin; iter != end; iter++){
        ans += (iter->second - 1) * (iter->second) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> table(H);
  for (int i = 0; i < H; i++) cin >> table.at(i);

  vector<string> result(H);
  for (int j = 0; j < W; j++) {
    bool flag = false;
    for (int i = 0; i < H; i++) {
      if (table.at(i).at(j) == '#') {
        flag = true;
        break;
      }
    }
    if (flag) {
      for (int i = 0; i < H; i++) {
        result.at(i) += table.at(i).at(j);
      }
    }
  }

  for (int i = 0; i < H; i++) {
    if (result.at(i).find('#') != string::npos) {
      cout << result.at(i) << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (b - a == c - b)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
using namespace std;
int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S;
	cin >> T;
	for (auto i = 0; i < (int)S.size(); i++)
	{
		if (S[i] != T[i])
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}	

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll x;
    cin>>x;
    
    ll f=x%11;
    ll t=(x/11);
    if(f==0){
        cout<<t*2;
    }else if(f<=6){
        cout<<t*2+1;
    }else{
        cout<<(t+1)*2;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
pi p[100000];
bool saw[100000];
vector<int> x[100000], y[100000];
queue<int> que;

int main() {
    cin >> n;
    rep(i,n) {
        cin >> p[i].first >> p[i].second;
        p[i].first--; p[i].second--;
        x[p[i].first].push_back(i);
        y[p[i].second].push_back(i);
    }
    ll ans = 0;
    rep(i,n) {
        if (saw[i]) continue;
        que.push(i);
        saw[i] = true;
        set<int> sx, sy;
        ll sum = 1;
        while (!que.empty()) {
            int q = que.front(); que.pop();
            sx.insert(p[q].first);
            sy.insert(p[q].second);
            for (int j : x[p[q].first]) {
                if (saw[j]) continue;
                saw[j] = true;
                que.push(j);
                sum++;
            }
            for (int j : y[p[q].second]) {
                if (saw[j]) continue;
                saw[j] = true;
                que.push(j);
                sum++;
            }
        }
        ans += (ll)sx.size()*(ll)sy.size()-sum;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int l,r;
    cin >>l>>r;
    int d=r-l;
    l=l%2019;
    if(2019*3>d){r=l+d;}
    else{r=(r%2019)+2019*3;}
    int a=2018;
    for(int i=l;i<r;i++){
        for(int j=i+1;j<r+1;j++){
            a= min(a,(i*j)%2019);
        }
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

class List{
public:
    struct node{
        node* front;
        node* back;
        ll a;
        
        node(node* x,node* b,ll A=-1){
            front=x;
            back=b;
            a=A;
        }
        
        node(){
            front=NULL; back=NULL; a=-1;
        }
    };
    
    vector<node*> M;
    
    node root;
    
    List(vector<ll> A):root(NULL,NULL){
        M.resize(A.size()+1,NULL);
        node* L=&root;
        for(int i=0;i<A.size();i++){
            node* w=(node*)malloc(sizeof(node));
            (*L).back=w;
            (*w).front=L;
            (*w).a=A[i];
            M[A[i]]=w;
            L=w;
        }
        root.front=L;
        (*L).back=&root;
    }
    
    void swap(ll q){
        node* B=M[q];
        node* AL=(*B).front;
        node* AS=root.back;
        node* CS=(*B).back;
        node* CL=root.front;
        if(CS==&root){
            root.front=AL;
            root.back=B;
            (*AL).back=&root;
            (*B).front=&root;
            (*B).back=AS;
            (*AS).front=B;
        }
        else if(AL==&root){
            (*B).back=&root;
            root.front=B;
            (*CS).front=&root;
            root.back=CS;
            (*CL).back=B;
            (*B).front=CL;
        }
        else{
            (*CL).back=B;
            (*B).front=CL;
            (*AS).front=B;
            (*B).back=AS;
            (*AL).back=&root;
            root.front=AL;
            (*CS).front=&root;
            root.back=CS;
        }
    }
    
    void show(){
        node* where=root.back;
        cout<<(*where).a;
        where=(*where).back;
        while(where!=&root){
            cout<<" "<<(*where).a;
            where=(*where).back;
        }
        cout<<endl;
    }
};




int main(){
    ll n,q;
    cin>>n>>q;
    vector<ll> a(n);
    if(n==1){cout<<1<<endl; return 0;}
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    List L(a);
    //L.show();
    while(q--){
        ll Q;
        cin>>Q;
        //cout<<q<<endl;
        L.swap(Q);
    }
    //cout<<"!"<<endl;
    L.show();
    
    return 0;
}



Measured memory_bytes: 8312
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	if (s.size() < 4){
		cout << "No\n";
		return 0;
	}
	s.resize(4);
	if (s == "YAKI") {
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <stdint.h>
#include <string>
using namespace std;
uint64_t ppow = 1000000000 + 7;
int main()
{
	uint64_t out = 1;
	int N;
	cin >> N;
	for (uint64_t i = 1;i <= N;i++) {
		out = (out * i) % ppow;
	}
	cout << out;
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    rep(i,n) {
        cin >> a[i];
    }
    rep(i,m) {
        cin >> b[i];
    }
    bool ok;
    rep(i,n-m+1) {
        rep(j,n-m+1) {
            ok = true;
            rep(k,m) {
                if (a[i+k].substr(j, m) != b[k]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import * as fs from 'fs';

//in
// abcdabc
//out
// 2
const main = (inp: string) => {
    let ans: number = 0;

    for (let i = 0; i < Math.floor(inp.length / 2); i++) {
        if (inp[i] !== inp[inp.length - i - 1]) {
            ans++;
        }
    }
    console.log(ans);
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


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


int dx[]={-2,-1,0,-2,-1,0,-2,-1,0};
int dy[]={-2,-2,-2,-1,-1,-1,0,0,0};

map<pair<int,int>,bool>m;
set<pair<int,int> >st;
int cnt;

int y[100009],x[100009],n,h,w;

signed main(){
	cin>>h>>w>>n;
	rep(i,n){
		cin>>y[i]>>x[i];
		y[i]--;x[i]--;
		m[P(y[i],x[i])]=true;
	}
	int sum=(h-2)*(w-2);
	int a[10]={};
	rep(i,n){
		rep(j,9){
			int sum=0;
			int yy=y[i]+dy[j];
			int xx=x[i]+dx[j];
			if(yy<0||xx<0||yy+2>=h||xx+2>=w)continue;
			if(st.count(P(yy,xx)))continue;
			rep(k,9){
				int ny=yy+(dy[k]*-1);
				int nx=xx+(dx[k]*-1);
				if(m[P(ny,nx)])sum++;
			}
			//cout<<yy<<' '
			st.insert(P(yy,xx));
			a[sum]++;
			cnt++;
		}
	}
	a[0]+=sum-cnt;
	rep(i,10)cout<<a[i]<<endl;
}

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

int main()
{
    int x;
    cin >> x;
    int num;
    int ma = 1;
    for(int i = 1; i < x; i++){
        for(int j = 2; j < x; j++){
            num = 1;
            for(int k = 1; k <= j; k++){
                num *= i;
            }
            if(num > x) break;
            ma = max(ma,num);
        }
    }
    cout << ma << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  while(n != 0 || m != 0){
    vector <vector<int> > nm(n,vector<int>(m,0));
    vector <int> cnt(m,0);
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ;j < m ; j++ ){
        cin >> nm[i][j];

        if(nm[i][j] == 1){
          cnt[j]++;
        }
      }
    }
    int spacecnt = 0;
    for(int i = n ; i >= 0 ; i--){
      for(int j = 0 ; j < m ; j++){

        if(cnt[j] == i){
          cout << j+1;
          spacecnt++;
          if(spacecnt < m){
            cout << " ";
          }
        }
      }
    }
    cout << endl;
    cin >> n >> m;
  }
  return 0;
}


Measured memory_bytes: 3336
#include<stdio.h>

int main(void)
{
  int matrix[9][2]={0};
  char array[9][15]={};
  int matrix_h[9]={0};
  int matrix_m[9]={0};
  int i;

  for( i=0; i<9; i++ ){
    scanf("%s %d %d",&array[i],&matrix[i][0],&matrix[i][1]);
  }
  for( i=0; i<9; i++ ){
    matrix_h[i]+=matrix[i][0]+matrix[i][1];
  }
  for( i=0; i<9; i++ ){
    matrix_m[i]+=200*matrix[i][0]+300*matrix[i][1];
  }
  for( i=0; i<9; i++ ){
    printf("%s %d %d\n",array[i],matrix_h[i],matrix_m[i]);
  }
  return 0;
}

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

int n,s,e;
int d[100005];
int t[100000];

int main()
{
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d",&d[i]);
    }
    int flag = 1;
    long long sum = 0;
    int mid = n/2+1;
    s = 1;
    e = n;
    for(int i = 1; i < mid; i++)
    {
        t[i] = d[s]+d[e];
        s++;
        e--;
    }
    t[mid] = d[mid];
    for(int i = 1; i <= mid; i++)
    {
        if(flag&1)
            sum += t[i];
        else
            sum -= t[i];
        flag++;
    }
    printf("%d ",sum);
    int temp = sum;
    for(int i = 1; i < n; i++)
    {
        temp = 2*d[i]-temp;
        if(i != n-1)
            printf("%d ",temp);
        else
            printf("%d\n",temp);
    }
    return 0;
}


Measured memory_bytes: 1920
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

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

const ll mod = 1e9+7;

int main() {
	int n;
	cin >> n;
	vi a(n+1);

	vi x(n + 1);

	REP(i, n + 1) {
		x[i] = i;
		a[i] = 0;
	}

	FOR(i, 2, n+1) {
		FOR(j, 2, n + 1) {
			while (x[j] % i == 0) {
				a[i]++;
				x[j] = x[j] / i;
			}
		}
	}

	ll ans = 1;
	FOR(i, 2, n + 1) {
		ans = ans * (a[i] + 1) % mod;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,m;
int c[500001]={};
int lowbit(int a){return a&-a;}
void add(int k,int x)
{
    while (k<=n)
    {
        c[k]+=x;
        k+=lowbit(k);
    }
    return;
}
int num(int xd)
{
    int sum=0;
    while (0<xd)
    {
        sum+=c[xd];
        xd-=lowbit(xd);
    }
    return sum;
}
int main()
{
    scanf("%d%d",&n,&m);
    int l,r;
    for (int i=1;i<=m;i++)
    {
    	scanf("%d%d",&l,&r);
        add(l,1);
        add(r+1,-1);
    }
    int ans=0;
    for (int i=1;i<=n;i++)
    {
//    	printf("%d\n",num(i));
    	if (num(i)==m) ans++;
	}
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,x,y; cin>>n>>x>>y;
  vector<ll> d(n, 0);
  for (int i=1; i<=n; i++) {
    for (int j=i+1; j<=n; j++) {
      ll a = abs(j-i);
      ll b = abs(x-i) + abs(y-j) + 1;
      ll c = abs(i-y) + abs(x-j) + 1;
      ll t = min(a, min(b, c));
      d[t]++;
    }
  }
  for (int i=1; i<n; i++) {
    cout << d[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

struct edge {ll to, cost;};
//=============dijkstra============================
vector<ll> dijkstra(ll s, ll V, vector<vector<edge>>& G)
{
  vector<ll> d(V, INF);
  typedef pair<ll, ll> P;// first は最短距離　second は頂点の番号
  priority_queue<P, vector<P>, greater<P>> que;
  d.at(s) = 0;
  que.push(P(0, s));
  while (!que.empty())
  {
    P p = que.top();
    que.pop();
    ll v = p.second;
    if (d.at(v) < p.first) continue;
    for (ll i = 0; i < G.at(v).size(); ++i)
    {
      edge e = G.at(v).at(i);
      if (d.at(e.to) > d.at(v) + e.cost)
      {
        d.at(e.to) = d.at(v) + e.cost;
        que.push(P(d.at(e.to), e.to));
      }
    }
  }
  return d;
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vector<vector<edge>> G(N);
  for (ll i = 0; i < M; ++i) {
    ll L, R, C;
    cin >> L >> R >> C;
    L -= 1;R -= 1;
    G.at(L).push_back({R, C});
  }
  for (ll i = 1; i < N - 1; ++i) {
    G.at(i + 1).push_back({i, 0});
  }
  ll ans = dijkstra(0, N, G).at(N - 1);
  if (ans == INF) {
    cout << -1 << "\n";
  }
  else {
    cout << ans << "\n";
  }
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
using ll = long long int;

using namespace std;

int main() {
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  S[K-1] += 'a' - 'A';
  cout << S << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int lli;
#define rep(i,a,b) for(int i=(a);i<(b);i++)

int dat[100005][2],sdat[2][100005];
int w,h,n;
int main(void){
	scanf("%d%d%d",&w,&h,&n);
	rep(i,0,n){
		int a,b;
		scanf("%d%d",&a,&b);
		dat[i][0]=a;dat[i][1]=b;
		sdat[0][i]=a;sdat[1][i]=b;
	}
	sort(sdat[0],sdat[0]+n);
	sort(sdat[1],sdat[1]+n);
	int c[2]={},ansp[2]={-1,-1};
	lli ans=-1;
	
	rep(i,n/2-10,n/2+11){
		rep(j,n/2-10,n/2+11){
			if(i<0 || i>=n || j<0 || j>=n)continue;
			c[0]=sdat[0][i];c[1]=sdat[1][j];
			lli nd=0,nm=-1,ns;
			rep(k,0,n){
				ns=abs(c[0]-dat[k][0])+abs(c[1]-dat[k][1]);
				nd+=ns*2;
				if(nm==-1 || nm<ns)nm=ns;
			}
			nd-=nm;
			if(ans==-1 || nd<ans){
				ans=nd;
				ansp[0]=c[0];
				ansp[1]=c[1];
			}
		}
	}
	
	printf("%lld\n%d %d\n",ans,ansp[0],ansp[1]);
	return 0;
}

Measured memory_bytes: 2600
def main():
    text = input()
    words = ['dreamer', 'eraser', 'dream', 'erase']
    length = len(text)
    while text:
        for word in words:
            if text.endswith(word):
                text = text[:-len(word)]
        else:
            if (new := len(text)) != length:
                length = new
            else:
                return 'NO'
    return 'YES'


if __name__ == '__main__':
    ans = main()
    print(ans)


Measured memory_bytes: 9164
import sys, math, copy
input = sys.stdin.readline

N, K = map(int, input().split())
S = list(input().replace('\n',''))
S = list(map(int, S))

group = [0]

for i in range(1,N):
    if S[i-1] != S[i]:
        group.append(i)

ans = 0
for i in range(len(group)):
    start = group[i]
    if(S[start] == 1):
        end_group_id = i + 2 * K + 1
    else:
        end_group_id = i + 2 * K
    if end_group_id < len(group):
        end = group[end_group_id]
    else:
        end = len(S)
    ans = max(ans, end - start)

print(ans)

Measured memory_bytes: 52472
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

int main(){
    int a, b;
    cin >> a >> b;
    if(a%2 == 1 && b%2 == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int n,a[110000];
const int INF = 1001001001;
int dp[110000];
int dfs(int x){
	//1 kara x
	if(x == 1)return 0;
	if(dp[x] != -1)return dp[x];
	int ret = INF;
	if(x-1 >= 1)ret = min(ret,dfs(x-1) + abs(a[x] - a[x-1]));
	if(x-2 >= 1)ret = min(ret,dfs(x-2) + abs(a[x] - a[x-2]));
	return dp[x] = ret;
}
signed main(){
	cin >> n;
	rep(i,n)cin >> a[i+1];
	rep(i,110000)dp[i] = -1;
	cout <<dfs(n) << endl;
	return 0;
}

Measured memory_bytes: 9892
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");

		for (int i = 0; i < 3; i++) {
			String x = array[i];
			System.out.print(x.charAt(0));
		}
		System.out.println("");

	}
}


Measured memory_bytes: 22996
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

int main(){
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    lint odd = 0, even = 0;
    rep(i, n){
        cin >> a[i];
        if(a[i] % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }
    lint comb[55][55];
    rep(i, n+1){
        comb[i][0] = 1;
    }
    REP(i, 1, n+1){
        REP(j, 1, i+1){
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
        }
    }
    lint ans = 0;
    if(p == 0){
        for(int i = 0 ; i <= odd ; i += 2){
            for(int j = 0 ; j <= even ; j++){
                ans += comb[odd][i] * comb[even][j];
            }
        }
    }else{
        for(int i = 1 ; i <= odd ; i += 2){
            for(int j = 0 ; j <= even ; j++){
                ans += comb[odd][i] * comb[even][j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

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


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  string s,t;
  cin>>n;
  cin>>s>>t;
  vector<int> v;
  rep(i,n){
    if(s[i]!=t[i]){
      i++;
      v.push_back(0);
    }else{
      v.push_back(1);
    }
  }
  int ans=1;
  int prev=v[0];
  if(v[0]) ans=3;
  else ans=6;
  repi(i,1,v.size()){
    if(prev){
      if(v[i]) ans*=2;
      else ans*=2;
      ans%=MOD;
      prev=v[i];
    }else{
      if(v[i]){
	ans*=1;
      }else{
	ans*=3;
      }
      ans%=MOD;
      prev=v[i];
    }
  }
  cout<<ans<<endl;

  return 0;
}

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

struct Point { double x, y; };

void koch(int n, Point a, Point b)
{
  if (n == 0) {
    return;
  }

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main()
{
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}

Measured memory_bytes: 2704
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    long long int t[n];
    for(int p=1;p<n+1;p++)
    {
        scanf("%lld",&t[p]);
    }
    long long int a,b;
    int x=0;
    for(int q=1;q<n;q++)
    {
        a=t[q];
        b=t[q+1];
        while(a!=0 && b!=0)
        {
            if(a>b)
            {
              a=a%b;
              x++;
            }
            else if(a<b && x==0)
            {
              b=b%a;
              x++;
            }
            else if(a==b && x==0)
              a=0;
            x=0;
        }
        t[q+1]=(t[q]/(a+b))*t[q+1];
    }
    printf("%lld",t[n]);
}

Measured memory_bytes: 128
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()

Measured memory_bytes: 21532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		String str = scan.next();
		String str1;
		String str2;

		if(num % 2 == 0) {
			str1 = str.substring(0, num/2);
			str2 = str.substring(num/2, num);
			if (str1.equals(str2)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}

	}


}

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

int main()
{
	int n, k;
	cin >> n >> k;
	auto b = vector<bool>(10);
	for(auto i = 0; i < k; ++i){
		int d;
		cin >> d;
		b[d] = true;
	}
	auto check = [&b](int n) -> bool {
		while(n > 0){
			int t = n % 10;
			if(b[t]) return true;
			n /= 10;
		}
		return false;
	};
	while(check(n)) ++n;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256