akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int ans[SIZE];

int main(){
  int Q;
  int MAXN = 100000;

  cin >> Q;

  for (int i=2; i<=MAXN; i++) {
    int counter = 0;
    for (int j=2; j*j<=i; j++) {
      counter += (i % j == 0) * ((j * j != i) + 1);
    }

    ans[i] = (counter >= 3) + ans[i-1];
  }

  for (int i=0; i<Q; i++) {
    int N;
    cin >> N;
    cout << ans[N] << '\n';
  }

  return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int D, G, ans = 1e9;
int P[10], C[10];

bool now[10];

int Judge(int num){
  for (int i = 0; i < D; i++){
    now[i] = num % 2;
    num /= 2;
  }
  return 0;
}

int Solve(int num){
  Judge(num);
  int cnt = 0, sum = 0;
  for (int i = 0; i < D; i++){
    if (!now[i]) continue;
    cnt += P[i];
    sum += P[i] * (i+1) * 100 + C[i];
  }

  int rest = G - sum;
  if (rest <= 0){
    ans = min(ans, cnt);
    return 0;
  }

  for (int i = 0; i < D; i++){
    if (now[i]) continue;

    int res = rest / ((i+1)*100);
    if (rest % ((i+1)*100) > 0) res++; 

    if (res > P[i]) continue;
    ans = min(ans, cnt + res);
  }

  return 0;
}

int main(){
  cin >> D >> G;
  for (int i = 0; i < D; i++){
    cin >> P[i] >> C[i];
  }
  for (int i = 0; i < (1<<D); i++){
    Solve(i);
  }
  cout << ans << endl;

  return 0;
}


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

using ll = long long;
const int INF = 1001001001;

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

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

  rep(i,3) {
    int tmp = n / pow(10,i);
    if (tmp % 10 == 7) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3808
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<list>
#include<iomanip>
#include<vector>
using ll = long long;
using namespace std;
const ll MM = 1000000000;
const ll mod = MM + 7;

int main(){
    int n; cin >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int f = 0, c = 1;
    b[0] = 1;
    for(int i = 0; i < n; i++){
        f = a[f] - 1;
        if(f == 1) break;
        else if(b[f] == 0){
            b[f] = 1; c += 1;
        } else {
            c = -1;
            break;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<string>
using namespace std;
int x;
int find(vector<vector<int> > ans,vector<int> temp,int start){
	if(start>ans.size())
	return -1;
	int res=INT_MAX;
	int flag=0;
	for(int i=0;i<temp.size();i++){
		if(temp[i]<x)
		flag=1;
	}
	if(flag==0)
	return 0;
	if(start==ans.size())
	return -1;
	for(int i=start;i<ans.size();i++){
		vector<int> k=temp;
		for(int j=1;j<ans[0].size();j++){
			k[j-1]+=ans[i][j];
		}
		int g=find(ans,k,i+1);
		if(g==-1)
		continue;
		if(g>=0)
		res=min(res,g+ans[i][0]);
	}
	return res==INT_MAX?-1:res;
}
int main(){
int n,m;
cin>>n>>m>>x;
vector<vector<int> > ans(n,vector<int> (m+1,0));
for(int i=0;i<n;i++){
	for(int j=0;j<=m;j++){
		cin>>ans[i][j];
	}
}
vector<int> temp(m,0);
cout<<find(ans,temp,0)<<"\n";
 
}

Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    ll res = 0;
    vector<vector<ll>> num(10, vector<ll>(10, 0));
    repi(i, n + 1, 1)
    {
        vector<int> d;
        ll nn = i;
        while(nn){
            d.push_back(nn % 10);
            nn /= 10;
        }
        ll a = d[0];
        ll b = d.back();
        if(!a || !b)continue;
        num[a][b]++;
    }
    repi(a,10,1){
        repi(b,10,1){
            res += num[a][b] * num[b][a];
        }
    }
    cout << res << endl;
    return 0;
}

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

using ll = long long;

int main() {
    ll n, x; cin >> n >> x;

    ll target = x, ans = 0;
    vector<ll> paty(n + 1), sum(n + 1);
    paty[0] = sum[0] = 1;
    for(int i = 1; i <= n; ++i) {
        paty[i] = paty[i - 1] * 2 + 1;
        sum[i] = sum[i - 1] * 2 + 3;
    }
    for(int i = n; i >= 1; --i) {
        target -= 1;
        if(sum[i - 1] <= target) {
            ans += paty[i - 1];
            if(sum[i - 1] == target) {
                target = 0;
            } else {
                target -= sum[i - 1] + 1;
                ans += 1;
                if(target >= sum[i - 1]) {
                    target -= sum[i - 1] + 1;
                    ans += paty[i - 1];
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
  vector<int> ns(3);
  cin >> ns[0] >> ns[1] >> ns[2];
  int K;
  cin >> K;
  sort(ns.begin(), ns.end(), greater<int>());
  for(int i = 0; i < K; ++i) {
    ns[0] *= 2;
  }
  auto ans = accumulate(ns.begin(), ns.end(), 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Jigsaw Puzzle
public class Main{

	int h, w, n;
	int[] puzzle;
	List<R>[] piece;
	boolean[] res;
	
	class R{
		int H, W;
		int[] p;
		String str;
		public R(int h, int w, char[][] m) {
			H = h;
			W = w;
			p = new int[H];
			str = "";
			for(int i=0;i<H;i++)for(int j=0;j<W;j++){
				p[i] = (p[i]<<1) + (m[i][j]=='#'?1:0);
				str+=m[i][j];
			}
		}
		boolean eq(R r){
			if(H!=r.H || W!=r.W)return false;
			return str.equals(r.str);
		}
	}
	
	char[][] rot(char[][] a){
		int H = a.length, W = a[0].length;
		char[][] res = new char[W][H];
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)res[W-j-1][i] = a[i][j];
		return res;
	}
	
	void dfs(int i, int j, int U, int idx){
		if(j==w){
			dfs(i+1, 0, U, 0); return;
		}
		if(i==h){
			res[U] = true; return;
		}
		for(int u=idx;u<n;u++)if(((U>>u)&1)==0){
			for(R r:piece[u]){
				if(h < i+r.H || w < j+r.W)continue;
				boolean ok = true;
				for(int y=0;y<r.H;y++)if( (puzzle[i+y] & (r.p[y]<<(w-r.W-j))) != (r.p[y]<<(w-r.W-j))){
					ok = false; break;
				}
				if(!ok)continue;
				for(int y=0;y<r.H;y++){
					puzzle[i+y] ^= (r.p[y]<<(w-r.W-j));
				}
				if(((puzzle[i]>>(w-j-1))&1)==0){
					dfs(i, j, U | (1<<u), u+1);
				}
				for(int y=0;y<r.H;y++){
					puzzle[i+y] |= (r.p[y]<<(w-r.W-j));
				}
				
			}
		}
		if(((puzzle[i]>>(w-j-1))&1)==0)
			dfs(i, j+1, U, 0);
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		piece = new List[10];
		res = new boolean[1024];
		for(;;){
			h = sc.nextInt(); w = sc.nextInt();
			if((h|w)==0)break;
			puzzle = new int[h];
			for(int i=0;i<h;i++){
				char[] s = sc.next().toCharArray();
				for(char c:s)puzzle[i] = (puzzle[i]<<1) + (c=='#'?0:1);
			}
			n = sc.nextInt();
			for(int i=0;i<n;i++){
				piece[i] = new ArrayList<R>();
				int H = sc.nextInt(), W = sc.nextInt();
				char[][] m = new char[H][];
				for(int j=0;j<H;j++)m[j]=sc.next().toCharArray();
				piece[i].add(new R(H, W, m));
				for(int k=0;k<3;k++){
					m = rot(m);
					int t = H;
					H = W; W = t;
					piece[i].add(new R(H, W, m));
				}
				for(int j=0;j<piece[i].size();j++)for(int k=j+1;k<piece[i].size();k++)if(piece[i].get(j).eq(piece[i].get(k))){
					piece[i].remove(k--);
				}
			}
			Arrays.fill(res, false);
			dfs(0, 0, 0, 0);
			int Q = sc.nextInt();
			while(Q--!=0){
				int k = sc.nextInt(), S = 0;
				while(k--!=0)S|=(1<<(sc.nextInt()-1));
				System.out.println(res[S]?"YES":"NO");
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <list>
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define pb push_back
 
int INF = INT_MAX / 10;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string s; cin >> s;
	string ans;
	for (char c: s) {
		if (c == 'S') ans.push_back('S');
		else if (ans.length() && ans.back() == 'S') ans.pop_back();
		else ans.push_back('T');
	}
	cout << ans.length() << endl;
}


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

int main() {
    /* Input */
    int X, N;
    cin >> X >> N;

    vector<int> ng(N);
    rep (i, N) {
        cin >> ng.at(i);
    }

    /* Main Logic */   
    // Forbidden Listを除いた数列を作成
    vector<int> ok(100 - N + 2);
    int tmpIndex = 1;
    
    ok.at(0) = 0;
    rep (i, 100) {
        bool ngMatchFlag = false;
        /* NG Listに一致するものがあるかどうか */
        rep (j, N) {
            if (ng.at(j) == i + 1) {
                ngMatchFlag = true;
                break;
            }
        }
        if(!ngMatchFlag) {
            ok.at(tmpIndex) = i + 1;
            tmpIndex++;
        }
    }
    ok.at(tmpIndex) = 101;

    int preDiff = 100;
    int nowDiff = 100;
    int preI = 0;

    rep (nowI, 100 - N + 2) {
        nowDiff = abs(ok.at(nowI) - X);
        if ( (nowDiff < preDiff) || (nowDiff == preDiff && ok.at(nowI) < ok.at(preI)) ) {
            preDiff = nowDiff;
            preI = nowI;
        }
    }
    
    /* Output */
    cout << ok.at(preI) << endl;
    return 0;
}

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

int main() {
	string s,t;
	cin >> s >> t;
	bool ans = true;
	rep(i,s.length()) if (s[i] != t[i]) ans = false;
	if (t.length() != s.length()+1) ans = false;
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>

const long long INF = 1000000000000000000LL;

int main() {
    int N;
    std::cin >> N;

    bool over = false;
    bool zero = false;
    long long res = 1;
    for (int i = 0; i < N; i++) {
        long long A;
        std::cin >> A;
        if (A == 0) {
            zero = true;
        } else if (INF / res < A) {
            over = true;
            res = 1;
        } else {
            res *= A;
        }
    }

    if (zero == true) {
        std::cout << 0 << "\n";
    } else if (over == false || zero == true) {
        std::cout << res << "\n";
    } else {
        std::cout << "-1\n";
    }
}

Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var X = input[1];
            var Y = input[2];
            var ans = new int[N];
            for (int i = 1; i < N; i++)
            {
                for (int j = i + 1; j <= N; j++)
                {
                    var min = int.MaxValue;
                    if (Math.Abs(X - i) <= Math.Abs(Y - i))
                    {
                        min = Math.Abs(X - i) + Math.Abs(Y - j) + 1;
                    }
                    else
                    {
                        min = Math.Abs(Y - i) + Math.Abs(X - j) + 1;
                    }
                    var len = Math.Min(j - i, min);
                    ans[len]++;
                }
            }
            for (int i = 1; i < N; i++)
            {
                Console.WriteLine(ans[i]);
            }

            Console.WriteLine();
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#define N 9
#define n 3
#define Blank 0
#define up -N/n
#define down N/n
#define left -1
#define right 1
#define limit 34
using namespace std;
struct p{
  int v[N];
  int blankPlace;
  int g=0;
  int h=0;
  bool operator < (const p& pazzle) const {
    for(int i=0;i<N;i++){
      if(v[i] == pazzle.v[i]) continue;
      return v[i]<pazzle.v[i];
    }
    return false;
  }
};
priority_queue <p, vector<p>, greater<p> > pazzle;
map <p,bool> existPazzle;
bool operator > (const p a,const p b){return a.h+a.g>b.h+b.g;};

int calculate_h(p this_pazzle,int i){
  if(i == this_pazzle.blankPlace ) return abs(i/n-(N-1)/n)+abs(i%n-(N-1)/n);
  else return abs(i/n-(this_pazzle.v[i]-1)/n)+abs(i%n-(this_pazzle.v[i]-1)%n);
}

p checkPazzle(p thisPazzle){
  thisPazzle.h = 0;
    for(int i=0;i<N;i++)
      thisPazzle.h += calculate_h(thisPazzle,i);
  return thisPazzle;
}

void moveBlank(p thisPazzle,int move){
  int moved = thisPazzle.blankPlace + move;
  thisPazzle.g++;
  //cout<<"g: "<<thisPazzle.g<<" moved: "<<moved<<endl;
  swap(thisPazzle.v[thisPazzle.blankPlace],thisPazzle.v[moved]);
  if(existPazzle[thisPazzle])return;
  thisPazzle.blankPlace = moved;
  thisPazzle = checkPazzle(thisPazzle);
  if(thisPazzle.g+thisPazzle.h>limit)return;
  pazzle.push(thisPazzle);
}

void movePazzle(p thisPazzle){
  if(thisPazzle.blankPlace+up>=0)
    moveBlank(thisPazzle,up);
  if(thisPazzle.blankPlace+down<9)
    moveBlank(thisPazzle,down);
  if(thisPazzle.blankPlace + left >= 0&&thisPazzle.blankPlace/3 == (thisPazzle.blankPlace+left)/3)
    moveBlank(thisPazzle,left);
  if(thisPazzle.blankPlace/3 == (thisPazzle.blankPlace+right)/3)
    moveBlank(thisPazzle,right);
}

p dfs(){
  p tmp,thisPazzle;
  tmp.g = -1;
  while(!pazzle.empty()){
    thisPazzle = pazzle.top();
    pazzle.pop();
    existPazzle[thisPazzle]=true;
    if(!thisPazzle.h)return thisPazzle;
    movePazzle(thisPazzle);
  }
  return tmp;
}

int main(){
  p thisPazzle;
  for(int i=0;i<N;i++){
    cin>>thisPazzle.v[i];
    if(thisPazzle.v[i]==Blank)thisPazzle.blankPlace=i;
  }
  thisPazzle = checkPazzle(thisPazzle);
  pazzle.push(thisPazzle);
  thisPazzle = dfs();
  cout<<thisPazzle.g<<endl;
  return 0;

}



Measured memory_bytes: 5544
// 2020.6.28
// https://atcoder.jp/contests/intro-heuristics
import java.util.*;

public class Main {

	public static int span; // 何日間のスケジューリングをするか
	public static int minus[]; // 26種類のコンテストの飽きやすさ
	public static int plus[][]; // 26種類のコンテストの満足感

	public static void main(String[] args) {

		// ----------
		// 入力
		// ----------
		Scanner sc = new Scanner(System.in);
		span = Integer.parseInt(sc.next()); // 何日間のスケジューリングをするか
		minus = new int[26]; // 26種類のコンテストの飽きやすさ
		for (int i = 0; i < 26; i++) {
			minus[i] = Integer.parseInt(sc.next());
		}
		plus = new int[span][26]; // 26種類のコンテストの満足感
		for (int d = 0; d < span; d++) {
			for (int i = 0; i < 26; i++) {
				plus[d][i] = Integer.parseInt(sc.next());
			}
		}

		// ----------
		// 入力(テストケース)
		// ----------
		int input[] = new int[span]; // 開催したコンテスト
		for (int d = 0; d < span; d++) {
			input[d] = Integer.parseInt(sc.next());
		}

		// ----------
		// 計算と出力
		// ----------
		calc(input);

	}

	public static void calc(int[] input) {

		int last[] = new int[26]; // 各コンテストが最終開催日から何日経過しているか
		int result = 0; // ユーザ満足度

		for (int d = 0; d < span; d++) {

			// lastの更新
			for (int i = 0; i < 26; i++) {
				if (i == input[d] - 1) {
					last[i] = 0;
				} else {
					last[i]++;
				}
				// System.out.println("last[" + i + "] = " + last[i]);
			}

			// 開催による満足度アップ
			result += plus[d][input[d] - 1];

			// 日数経過による満足度ダウン
			for (int i = 0; i < 26; i++) {
				result -= minus[i] * last[i];
				// System.out.println(minus[i] * last[i]);
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 41848
#include<bits/stdc++.h>
using namespace std;
int main () {
	int n;
	cin >> n;
	long long s = 0;
	long long mi = 1e9;
	for (int i=0; i<n; i++) {
		int x; cin >> x;
		if (x%10!=0 && x < mi) mi = x;
		s += x;
	}
	if (mi == 1e9) cout << 0;
	else {
		if (s%10!=0) cout << s;
		else cout << s-mi;
	}
	return 0;
}

Measured memory_bytes: 3572
package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N, M := sc.i(), sc.i()
	m := 0
	for i := 0; i < M; i++ {
		m += sc.i()
	}
	if m > N {
		fmt.Println("-1")
	} else {
		fmt.Println(N - m)
	}

}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i'|| c == 'u'|| c == 'e'|| c == 'o')
		cout << "vowel" << "\n";
	else
		cout << "consonant" << "\n";
}

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

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    string s;
    cin>>s;
    if(s == "ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iiii tuple<int, int, int, int>
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define dd pair<double, double>
#define fi first
#define vi vector<int>
#define vvi vector<vector<int>>
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int M = 1e3;

double f(vector<ii>& a, double x, double y) {
    double res = 0;
    for (auto& i : a)
        res = max(res, (i.fi - x) * (i.fi - x) + (i.se - y) * (i.se - y));
    return res;
}

int check(vector<ii>& a, vector<dd>& go, double L, double x, double y) {
    double org = f(a, x, y);
    int res = -1;
    for (int i = 0; i < go.size(); ++i) {
        double tmp = f(a, x + L * go[i].fi, y + L * go[i].se);
        if (tmp < org) {
            org = tmp;
            res = i;
        }
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<ii> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i].fi >> a[i].se;
    vector<pair<double, double>> go(360);
    const double PI = acos(-1);
    for (int i = 0; i < 360; ++i) {
        go[i].fi = sin(PI * i / 180);
        go[i].se = cos(PI * i / 180);
    }
    double L = 1000, cnt = 1000;
    double x = 0, y = 0;
    while (cnt--) {
        int cnt_check = 10, t = check(a, go, L, x, y);
        while (t == -1 && cnt_check--) {
            L /= 2;
            t = check(a, go, L, x, y);
        }
        x += go[t].fi * L;
        y += go[t].se * L;
    }
    cout << fixed << setprecision(15) << sqrt(f(a, x, y)) << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 512
if __name__ == "__main__":
	n = int(input())
	A = [[0 for j in range(n)] for i in range(n)]
	for _ in range(n):
		command = list(map(int, input().split()))
		u = command[0]
		k = command[1]
		for l in range(k):
			v = command[l + 2]
			A[u - 1][v - 1] = 1
	for i in range(n):
		print(*A[i])


Measured memory_bytes: 6384
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  ll sa=0,sb=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sa+=a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
    sb+=b[i];
  }
  ll num=sb-sa;
  if(num<0)cout<<"No"<<endl;
  else{
    ll cnt=0;
    for(int i=0;i<n;i++){
      if(a[i]-b[i]>0){
	cnt+=a[i]-b[i];
      }
    }
    if(cnt>num)cout<<"No"<<endl;
    else{
      ll cnt2=0;
      ll cnt3=cnt;
      bool ans=false;
      for(int i=0;i<n;i++){
	if(a[i]-b[i]<0){
	  if((b[i]-a[i])%2){
	    if(cnt3>=(b[i]-a[i])/2){
	      cnt3-=(b[i]-a[i])/2;
	      cnt++;
	    }else{
	      ll aaa=(b[i]-a[i]);
	      aaa-=cnt3*2;
	      cnt+=aaa;
	    }
	  }else{
	    if(cnt3>=(b[i]-a[i])/2){
	      cnt3-=(b[i]-a[i])/2;
	    }else{
	      ll aaa=(b[i]-a[i]);
	      aaa-=cnt3*2;
	      cnt+=aaa;
	    }
	  }
	}
	if(cnt>num)ans=true;
	if(ans)break;
      }
      if(ans)cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main{
	public static void main(String args[]){
      Scanner in = new Scanner(System.in);  
      int x = in.nextInt();
      int y = in.nextInt();
      boolean flag = false;
      for (int i = 0; i <= x; i++){
        if (2 * i + 4 * (x - i) == y){
          flag = true;
          System.out.println("Yes");
        }
      }
      
      if (!flag)
        System.out.println("No");
    }
}


Measured memory_bytes: 35608
N, T = map(int, input().split())
t = list(map(int, input().split()))

sum = 0
start = t[0]
end = t[0] + T

for i in range(N - 1):
    if end >= t[i + 1]:
        sum += t[i + 1] - start
        start = t[i + 1]
        end = t[i + 1] + T
    else:
        sum += end -start
        start = t[i + 1]
        end = t[i + 1] + T

sum += end - start

print(sum)


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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

std::vector< std::vector<ll>  > v(10000000), p(10000000);
ll o=1;
ll c=0;
std::vector<ll> vis(10000000,0);
std::vector<ll> sa(10000000,0);
std::vector<ll> pp(10000000,0);
void dfs(ll s)
{
	if(vis[s]==0)
	{
		vis[s]=o;
		c++;
		for(ll i=0;i<v[s].size();i++)
		{
			dfs(v[s][i]);
		}
	}
}



int main()
{
	//#ifdef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	ll n,m,k;
	cin>>n>>m>>k;

	f(m)
		{	ll x,y;
			cin>>x>>y;
			v[x].push_back(y);
			v[y].push_back(x);
		}

	f(k){
		ll x,y;
		cin>>x>>y;
		p[x].push_back(y);
		p[y].push_back(x);
	}
	for(ll i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
			dfs(i);
			sa[o]=c;
			c=0;
			o++;
		}
	}
	// for(ll i=1;i<=n;i++)
	// {
	// 	cout<<vis[i]<<" ";
	// }
	// cout<<endl;
	// for(ll i=1;i<o;i++)
	// {
	// 	cout<<sa[i]<<" ";
	// }
	// cout<<endl;
	// for(ll i=1;i<=n;i++)
	// {
	// 	cout<<v[i].size()<<" ";
	// }
	// cout<<endl;
	// for(ll i=1;i<=n;i++)
	// {
	// 	cout<<p[i].size()<<" ";
	// }
	// cout<<endl;
	ll d=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=0;j<p[i].size();j++)
		{
			if(vis[p[i][j]]==vis[i])
			{
				d++;
			}
		}
		pp[i]=d;
		d=0;
	}
	for(ll i=1;i<=n;i++)
	{
		cout<<sa[vis[i]]-v[i].size()-pp[i]-1<<" ";
	}
	
	
	return 0;
}

Measured memory_bytes: 711680
while t = gets
	a = [t.to_f, t.to_f * 2]
	4.times{|i|
		a[i*2+2] = a[i*2+1] / 3
		a[i*2+3] = a[i*2+2] * 2
	}
	sum = 0
	a.each{|t|
		sum += t
	}
	puts sum
end

Measured memory_bytes: 6112
#include <cstdio>
using namespace std;
int main(){
    int a,b,i;
    int sum=0;
    scanf("%d %d",&a,&b);
    for(i=1;i<=b-a;i++){
       sum = sum+i; 
    }
    printf("%d\n",sum-b);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int r;
	cin>>r;
	if(r<1200)cout<<"ABC";
	if(r<2800&&r>=1200)cout<<"ARC";
	if(r<=4208&&r>=2800)cout<<"AGC";	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  ll i,j;
  ll ans = 0;
  int n,a,b, stu = 0, all = 0;
  string s;
  cin >> n >> a >> b >> s;

  rep(i,n){
    if(s[i] == 'a'){
        if(all < a+b){
            all++; cout << "Yes" << endl;
        }
        else{cout << "No" << endl;}
    }
    else if(s[i] == 'b'){
        if(all < a+b && stu < b){
            all++; stu++; cout << "Yes" << endl;
        }
        else{cout << "No" << endl;}
    }
    else{
        cout << "No" << endl;
    }
  }

  return 0;
}


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

int main(){
	int a,b;
	double res;
	cin>>a>>b;
	res=((double)a+b)/2.0-(int)(a+b)/2;
	if(res<1e-9)cout<<(a+b)/2<<endl;
	else cout<<(a+b)/2+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 501
int n,m,ans;
bool xy[MAX][MAX],yz[MAX][MAX],xz[MAX][MAX];

void init(){
  ans=0;
  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      xy[i][j]=yz[i][j]=xz[i][j]=false;
}

int main(){
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    init();
    string str;
    int a,b;
    for(int i=0;i<m;i++){
      cin>>str>>a>>b;
      if(str=="xy"){
	xy[a][b]=true;
	for(int j=1;j<=n;j++)
	  if(!yz[b][j]&&!xz[a][j])ans++;
      }else if(str=="yz"){
	for(int j=1;j<=n;j++)
	  if(!xy[j][a]&&!xz[j][b])ans++;
	yz[a][b]=true;
      }else{
	xz[a][b]=true;
	for(int j=1;j<=n;j++)
	  if(!xy[a][j]&&!yz[j][b])ans++;
      }
    }
    cout<<n*n*n-ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1944
#include<bits/stdc++.h>
#define N 10100
using namespace std;
const int MOD=1e9+7;
struct Node{
	int x,y,v;
}e[N];
inline bool cmp(Node a,Node b){return a.v<b.v;}
int n,m,len;
int fa[N];
bool done[N<<1];
int nex[N<<2],to[N<<2],va[N<<2],beg[N];
long long x,tot;
inline void Add(int a,int b,int c){
	nex[++len]=beg[a],beg[a]=len,to[len]=b,va[len]=c;
	nex[++len]=beg[b],beg[b]=len,to[len]=a,va[len]=c;
}
int find_fa(int a){
	if(fa[a]==a) return a;
	fa[a]=find_fa(fa[a]);
	return fa[a];
}
int dfs(int p,int fa,int ma,int en){
	if(p==en) return ma;
	int maxx=0;
	for(int i=beg[p];i;i=nex[i]){
		if(to[i]!=fa){
			maxx=max(maxx,dfs(to[i],p,max(ma,va[i]),en));
		}
	}
	return maxx;
}
int main(){
	scanf("%d%d%lld",&n,&m,&x);
	for(int i=0;i<m;i++) scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].v);
	for(int i=1;i<=n;i++) fa[i]=i;
	sort(e,e+m,cmp);
	int use1=0,use2=0;
	for(int i=0;i<m;i++){
		int l=find_fa(e[i].x),r=find_fa(e[i].y);
		if(l!=r){
			Add(e[i].x,e[i].y,e[i].v);
			done[i]=1;
			use1++;
			fa[l]=r;
			tot+=e[i].v;
		}
	}
	for(int i=0;i<m;i++){
		if(!done[i]){
			int hf=dfs(e[i].x,0,0,e[i].y);
			if(tot-hf+e[i].v<x) use1++;
			else if(tot-hf+e[i].v==x) use2++;
		}
	}
	long long ans=1;
	if(tot==x){
		for(int i=0;i<use1+use2;i++) ans=ans*2%MOD;
		ans=(ans-2+MOD)%MOD;
		for(int i=use1+use2;i<m;i++) ans=ans*2%MOD;
	}
	else if(tot>x) ans=0;
	else{
		if(use2==0){
			puts("0");
			exit(0);
		}
		for(int i=0;i<use2;i++) ans=ans*2%MOD;
		ans=(ans-1+MOD)%MOD;
		ans=ans*2%MOD;
		for(int i=use1+use2;i<m;i++) ans=ans*2%MOD;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
/// IN THE NAME OF GUITAR
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
 
ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}
 
const ll MAXN = (1LL << 18) + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
pll mx[MAXN];
ll A[MAXN], n, res = 0;

void merge(pll &x, ll y) {
	if (x.S < y) x.S = y;
	if (x.F < x.S) swap(x.F, x.S);
}

int main() {
	scanf("%lld", &n);
	for (ll i = 0; i < 1LL << n; i++) {
		scanf("%lld", &A[i]);
		mx[i].F = A[i];
	}
	
	for (ll j = 0; j < n; j++) {
		for (ll i = 0; i < 1LL << n; i++) {
			if (i & (1LL << j)) {
				merge(mx[i], mx[i ^ (1LL << j)].F);
				merge(mx[i], mx[i ^ (1LL << j)].S);
			}
		}
	}
	
	for (ll i = 1; i < 1LL << n; i++) {
		res = max(res, mx[i].F + mx[i].S);
		printf("%lld\n", res);
	}
    return 0;
}
 

Measured memory_bytes: 9968
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void solve() {
		IOS;
		int n;
		cin >> n;
		vector<int> s(n);
		REP(i, n) {
			cin >> s[i];
		}
		sort(all(s));
		int q;
		cin >> q;
		vector<int> t(n);
		int cnt = 0;
		REP(i, q) {
			cin >> t[i];
			auto itr = lower_bound(all(s), t[i]);
			auto itr2 = upper_bound(all(s), t[i]);
			if (itr != itr2) {
				cnt++;
			}
		}
		put(cnt);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}



Measured memory_bytes: 3436
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    K = int(input())

    mod = 7
    ans = 1
    for i in range(K):
        if mod % K == 0:
            print(ans)
            exit()
        mod = (mod * 10 + 7) % K
        ans += 1
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
#define fov(i,x) for(auto &i : x)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> _ii;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int x;
    cin >> x;
    cout <<(x^1);
    return 0;
}


Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        n : usize,
        k : usize,
        h :[usize;n],
    }

    let mut cnt = 0;
    for elem in h {
        if elem >= k {
            cnt = cnt + 1;
        }
    }

    println!("{}", cnt);

}


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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  ll n ,d,cnt=1;
  set<ll> s;
  cin>>n;
  ll aux=1;
  if(n%7==0) 
   n/=7;
  
  while(1){
    if(s.find(aux)!=s.end()){
      cout<<"-1"; return 0;
    }
    
    if(aux%n==0)break;
    
    s.insert(aux); cnt++;
    aux%=n; aux = aux*10 +1;
  }
  cout<<cnt;
}   

Measured memory_bytes: 50420
#include<iostream>
#include<cstdio>
#include<cstring>

inline void check_max(int a,int &b){if(a>b)b=a;}

const int N=310,INF=1000000007;

int f[N][N][N];

char s[N];
int n,k;

int main()
{
	scanf("%s",s+1);
	scanf("%d",&k);
	n=strlen(s+1);

	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			for(int l=0;l<N;l++)
				f[i][j][l]=-INF;

	f[0][n+1][0]=0;
	
	for(int len=n+1;len>0;len--)
		for(int i=0;i+len<=n+1;i++)
		{
			int j=i+len;
			for(int l=0;l<=k;l++)
			{
				int v=f[i][j][l];
				if(v<0)continue;
				
				if(s[i+1]==s[j-1])
					check_max(v+1,f[i+1][j-1][l]);
				
				check_max(v,f[i+1][j][l]);
				check_max(v,f[i][j-1][l]);

				check_max(v+1,f[i+1][j-1][l+1]);
			}
		}

	int ans=0;

	for(int i=1;i<=n;i++)
		for(int l=0;l<=k;l++)
			check_max(f[i][i][l]*2-1,ans);
	for(int i=1;i<n;i++)
		for(int l=0;l<=k;l++)
			check_max(f[i][i+1][l]*2,ans);

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 116608
using System;
namespace AtCoder
{
    class Program
    {
        static int Gcd(int m, int n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        static int Gcd(int a, int b, int c) => Gcd(a, Gcd(b, c));

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            long sum = 0;
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= n; j++)
                    for (int k = 1; k <= n; k++)
                    {
                        sum += Gcd(i, j, k);
                    }
            System.Console.WriteLine(sum);
        }
    }
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> ss(m), cs(m);
	for (int i = 0; i < m; i++)
	{
		cin >> ss[i] >> cs[i];
		ss[i]--;
	}

	auto pow_orig = [](int a, int n) {
		int r = 1;
		for (; n; n >>= 1)
		{
			if (n & 1)
			{
				r *= a;
			}
			a *= a;
		}
		return r;
	};

	for (int x = 0; x < pow_orig(10, n); x++)
	{
		string s = to_string(x);

		if (s.size() != n)
		{
			continue;
		}

		bool f = true;
		for (int i = 0; i < m; i++)
		{
			f &= (s[ss[i]] == ('0' + cs[i]));
		}

		if (f)
		{
			cout << s << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

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


int main() {
  int n,t;
  cin >> n>>t;
  vector<int>a(n),b(n);
  rep(i,n){
    cin>>a.at(i)>>b.at(i);
  }
  bool ch=false;
  int ans=1001001001;
  rep(i,n){
    if(b.at(i)<=t){
      ans=min(ans,a.at(i));
      ch=true;
    }
  }
  if(ch){
    cout<<ans<<endl;
  }
  else{
    cout<<"TLE"<<endl;
  }
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    print(A[-1] - A[0])

if __name__ == "__main__": main()


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <cmath>

typedef long int li;

int main() {
    li n;
    li* m;

    std::cin >> n;
    m = new li[n];

    for (li i=0; i<n; ++i) {
        std::cin >> m[i];
    }

    std::sort(m,m+n);

    double mid = double(m[n-1])/2.;
    li r = -1;
    for (li i=0; i<n; ++i) {
        auto val = double(m[i]);
        if (std::abs(val-mid) < std::abs(double(r)-mid)) {
            r = m[i];
        } else {
            if (m[i] > mid) {
                break;
            }
        }
    }

    std::cout << m[n-1] << " " << r << std::endl;

    delete[](m);

    return 0;
}

Measured memory_bytes: 1024
// http://algorithms.blog55.fc2.com/blog-entry-66.html

#include <stdio.h>
#include <string.h>

#define M 100
int R[M+1],C[M][M],B[M][M];
void D(int i,int j){
	if(i==j)printf("M%d",i);
	else printf("("),D(i,B[i][j]-1),D(B[i][j],j),printf(")");
}

main(){
	int N,i=0,j,k,c;
	scanf("%d",&N);
	for(;i<N;i++)scanf("%d%d",R+i,&c);
	R[i]=c;
	memset(C,99,sizeof(C));
	for(i=0;i<N;i++)C[i][i]=0;
	for(j=1;j<N;j++)for(i=0;i<N-j;i++)for(k=i;k<i+j;k++)
		if((c=C[i][k]+C[k+1][i+j]+R[i]*R[k+1]*R[i+j+1])<C[i][i+j])C[i][i+j]=c,B[i][i+j]=k;
	printf("%d\n",C[0][N-1]);
	//order(0,N);
	//puts("");
}

Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	string divide[4] = {"dream","dreamer","erase","eraser"};
  	string s;
  	cin >> s;
  
  	reverse(s.begin(),s.end());
	for(int i=0;i < 4;i++) reverse(divide[i].begin(),divide[i].end());
  	
  	bool flag = true;
  	for(int i=0;i < s.size();){
      bool flag2 = false;
      for(int j=0;j < 4;j++){
        string d = divide[j];
        if(s.substr(i, d.size()) == d){
			flag2 = true;
          	i += d.size();
        }
      }
      if(!flag2){
		flag = false;
        break;
      }
    }
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int A, B;
  while (cin >> A >> B) {
    int C = 6 - A - B;
    cout << C << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char s[5];

int book[9];

int main(){

	cin>>s;
	int length=strlen(s);

	for (int i=0;i<length;i++){
		if (s[i]=='a') book[1]++;
		if (s[i]=='b') book[2]++;
		if (s[i]=='c') book[3]++;
	}

	for (int i=1;i<=3;i++){
		if (book[i]!=1){
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;

	return 0;

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
ll n, a, b;
Vector h;
bool jd(ll t){
  ll cnt = 0;
  rep(i,n)if(h[i] > t*b)cnt += ceil((double)(h[i] - t*b)/(double)(a-b));
  return cnt <= t;
}

int main(){
  cin.sync_with_stdio(false);
  cin >> n >> a >> b;
  h.resize(n);
  rep(i,n)cin >> h[i];
  ll l = 0,r = INF;
  rep(i,50){
    ll md = (l+r)/2;
    if(jd(md))r = md;
    else l = md;
  }
  cout << r << endl;
}


Measured memory_bytes: 1024
A, B = map(int, input().split())
ans = 0
if A % 2 == 0:
  if ((B + 1 - A) // 2) % 2 == 1:
    ans ^= 1
else:
  if ((B - A) // 2) % 2 == 1:
    ans ^= 1
  ans ^= A
if B % 2 == 0:
  ans ^= B
print(ans)

Measured memory_bytes: 61848