akhauriyash/Code-Regression huggingface dataset:
// ABC083

// inputに入力データ全体が入る
function Main(input) {
  input = input.split(" ");
  const N = parseInt(input[0],10);
  const A = parseInt(input[1],10);
  const B = parseInt(input[2],10);
  var sum = 0;
  for(var i=0;i<=N;i++) {
    // flagが0なら計算 1なら無視
    var flag = total(i,A,B)
    if(flag==0)sum += i;
  }
  console.log(sum)
}

function total(s,A,B) {
  var tmp = s.toString().split("");
  var sum = 0;
  var flag = 1;
  // 格桁の計算
  for(var i=0;i<tmp.length;i++) {
    sum += parseInt(tmp[i],10);
  }
  // 計算結果がA以上B以下か
  if(sum>=A && sum<=B) flag = 0;
  return flag;
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8496
#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int a, b;
	cin >> a >> b;
	cout << max(0, a - 2 * b) << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}



fn main() {
    let arr:Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = arr[0] as usize;
    let h = arr[1];

    let mut swords:i64 = 0;
    let mut throws = Vec::with_capacity(n);
    for _ in 0..n {
        let arr:Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        swords = cmp::max(swords, arr[0]);
        throws.push(arr[1]);
    }

    throws.sort_by(|a,b| b.cmp(a));

    let mut ans = 0;
    let mut idx = 0;
    let mut tmp = 0;
    while idx < n && tmp < h && throws[idx] > swords {
        tmp += throws[idx];
        idx += 1;
        ans += 1;
    }
    if tmp < h {
        ans += (h-tmp + swords - 1)/swords;
    }
    println!("{}", ans);

}


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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  string s, t;
  cin >> s >> t;
  s += s;

  bool f = false;
  range(i, 0, t.size()) {
    if (s.substr(i, t.size()) == t) f = true;
  }

  cout << (f ? "Yes" : "No") << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


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

typedef long long ll;
const int N = 200054;

struct node {
	int _0, _1, id;
	node (int _0_ = 0, int _1_ = 0, int id_ = 0) : _0(_0_), _1(_1_), id(id_) {}
	inline node & operator += (const node &B) {return _0 += B._0, _1 += B._1, *this;}
	inline bool operator < (const node &B) const {return (ll)_0 * B._1 < (ll)_1 * B._0 || ((ll)_0 * B._1 == (ll)_1 * B._0 && id > B.id);}
	inline bool operator == (const node &B) const {return _0 == B._0 && _1 == B._1;}
} v[N];

int n;
int p[N], dsu[N];
ll ans = 0;
std::priority_queue <node> pq;

int ancestor(int x) {return dsu[x] == x ? x : (dsu[x] = ancestor(dsu[x]));}

inline void Union(int x, int px) {ans += (ll)v[x]._0 * v[px]._1, v[px] += v[x], px == 1 || (pq.push(v[px]), 0), dsu[x] = px;}

int main() {
	int i, x; node t;
	scanf("%d", &n);
	for (i = 2; i <= n; ++i) scanf("%d", p + i);
	for (i = 1; i <= n; ++i) scanf("%d", &x), v[i] = node(!x, x, i);
	for (i = 2; i <= n; ++i) pq.emplace(v[i]);
	for (std::iota(dsu, dsu + (n + 1), 0); !pq.empty(); )
		if (t = pq.top(), pq.pop(), t == v[i = t.id]) Union(i, ancestor(p[i]));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 7924
#include<iostream>
#include<string>
#include<vector>
#define INF 1e9
using namespace std;
int main(){
int n,m,x;
cin>>n>>m>>x;
vector<int> c(n,0);
int A[n][m];
//vector<vector<int>> A(n, vector<int>(m,0));




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



int ans=INF, total_cost=0;
for(int i=0;i<(1<<n);i++){
    int price=0;
    vector<int> algo(m,0);
    total_cost=0;
    for(int j=0;j<n;j++){
        if(i>>j&1)
        {
            total_cost+=c[j];
            for(int k=0;k<m;k++)
                algo[k]+=A[j][k];
        }
    }
   
    bool  ok=true;
   // cout<<total_cost<<" ";
    for(int l=0;l<m && ok==true;l++){
      //  cout<<algo[l]<<" ";
        if(algo[l]<x){
            ok=false;
        }
            
    }
    //cout<<count<<endl;
    if(ok)
    ans= min(ans, total_cost);
}
if(ans==INF)
cout<<-1;
else
cout<<ans;


}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n;
  int k;
  cin >> n >> k;
  if (k == 0) {
    cout << n * n << endl;
    return 0;
  }

  ll ans = 0;
  rep(b, k + 1, n + 1) {
    ans += (n / b) * (b - k);
    ans += max(0LL, (n % b) - (k - 1));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char data[5];
    int a=0,b=0,ab=0,o=0;
    
    while(gets(data)!='\0'){
        if(strstr(data,"AB")!='\0'){
            ab++;
        }
        else if(strstr(data,"A")!='\0'){
            a++;
        }
        else if(strstr(data,"B")!='\0'){
            b++;
        }
        else if(strstr(data,"O")!='\0'){
            o++;
        }
    }
    
    printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
    return 0;
}

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

struct Answer { int start, end; };

Answer solve(string s)
{
    auto n = static_cast<int>(s.length());
    for (auto i = 0; i+1 < n; i++)
        if (s[i] == s[i+1])
            return {i, i+1};

    for (auto i = 0; i+2 < n; i++)
        if (s[i] == s[i+2])
            return {i, i+2};

    return {-2, -2};
}

int main()
{
    string s; cin >> s;
    auto answer = solve(s);
    cout << answer.start+1 << " " << answer.end+1 << endl;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while (null != (str = in.readLine())) {
				String[] sp = str.split(" ");
				printTree(sp[0].charAt(0), sp[1], sp[2]);
				System.out.println();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	static void printTree(char iu, String t1, String t2) {
		// System.out.println("[" + t1 + "][" + t2 + "]");
		if (iu == 'i' ?
				t1.length() == 0 || t2.length() == 0 :
					t1.length() == 0 && t2.length() == 0) {
			return;
		}
		String l1 = "", l2 = "", r1 = "", r2 = "";
		if (t1.length() > 0) {
			if (t1.charAt(1) == '(') {
				int level = 1;
				int i;
				for (i = 2; level > 0; i++) {
					if (t1.charAt(i) == '(') {
						level++;
					} else if (t1.charAt(i) == ')') {
						level--;
					}
				}
				l1 = t1.substring(1, i);
			} else {
				l1 = "";
			}
			r1 = t1.substring(1 + l1.length() + 1, t1.length() - 1);
		}
		if (t2.length() > 0) {
			if (t2.charAt(1) == '(') {
				int level = 1;
				int i;
				for (i = 2; level > 0; i++) {
					if (t2.charAt(i) == '(') {
						level++;
					} else if (t2.charAt(i) == ')') {
						level--;
					}
				}
				l2 = t2.substring(1, i);
			} else {
				l2 = "";
			}
			r2 = t2.substring(1 + l2.length() + 1, t2.length() - 1);
		}
		System.out.print("(");
		printTree(iu, l1, l2);
		System.out.print(",");
		printTree(iu, r1, r2);
		System.out.print(")");
	}
}

Measured memory_bytes: 10000
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var k = Integer.parseInt(br.readLine());

      if (k == 7) {
        System.out.println(1);
        return;
      }

      if (k == 10) {
        System.out.println(-1);
        return;
      }

      Set<Integer> done = new HashSet<>();
      int mod7 = 7 % k;
      int mod10 = 10 % k;
      int count = 1;

      int prev = 0;
      while (true) {
        int next = ((prev * mod10) % k + mod7) % k;

        if (done.contains(next)) {
          System.out.println(-1);
          return;
        }

        done.add(next);
        prev = next;

        if (next == 0) {
          System.out.println(count);
          return;
        }

        count++;
      }
    }
  }
}


Measured memory_bytes: 99864
sx,sy,tx,ty=gets.split.map(&:to_i)
result = ""
result += sx < tx ? "R" * (tx-sx) : "L" * (sx-tx)
result += sy < ty ? "U" * (ty-sy) : "D" * (sy-ty)
result += sx < tx ? "L" * (tx-sx) : "R" * (sx-tx)
result += sy < ty ? "D" * (ty-sy+1) : "U" * (sy-ty+1)
result += sx < tx ? "R" * (tx-sx+1) : "L" * (sx-tx+1)
result += sy < ty ? "U" * (ty-sy+1) : "D" * (sy-ty+1)
result += sx < tx ? "L" : "R"
result += sy < ty ? "U" : "D"
result += sx < tx ? "L" * (tx-sx+1) : "R" * (sx-tx+1)
result += sy < ty ? "D" * (ty-sy+1) : "U" * (sy-ty+1)
result += sx < tx ? "R" : "L"
puts result

Measured memory_bytes: 1916
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int m = in.nextInt();
		int l = in.nextInt();
		int[][] d = new int[n][n];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				d[i][j] = Integer.MAX_VALUE >> 1;
		for (int i = 0; i < m; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			int c = in.nextInt();
			if (c <= l) {
				d[a][b] = c;
				d[b][a] = c;
			}
		}
		int[][] ans = new int[n][n];
		solve(n, d, ans, l);
		int q = in.nextInt();
		for (int i = 0; i < q; i++) {
			int s = in.nextInt() - 1;
			int t = in.nextInt() - 1;
			if (ans[s][t] == Integer.MAX_VALUE >> 1)
				System.out.println(-1);
			else
				System.out.println(ans[s][t] - 1);
		}
		in.close();
	}

	private static void solve(int n, int[][] d, int[][] ans, int l) {
		for (int k = 0; k < n; k++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (d[i][j] <= l)
					ans[i][j] = 1;
				else
					ans[i][j] = Integer.MAX_VALUE >> 1;
		for (int k = 0; k < n; k++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					ans[i][j] = Math.min(ans[i][j], ans[i][k] + ans[k][j]);
	}
}

Measured memory_bytes: 112236
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
// you can alays change it such that atmost 1 equals sign exists
void solve(){
	int n; cin >> n;
	int a[n];
	FOR(n) cin >> a[i];
	ll ans = 0, minus = 0;
	FOR(n){
		if(a[i] < 0) ++minus;
		ans += abs(a[i]);
	}
	// remove smallest elm
	if(minus&1){
		int low = inf;
		FOR(n) low = min(low,abs(a[i]));
		ans -= 2*low;
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3912
// E - Knapsack 2
#include <bits/stdc++.h>
using namespace std;

// void dpprn(vector<int> &v, int inf){
// 	for(int i=0;i<v.size();i++){
// 		if(v[i]==inf) cout<<"∞"; else cout<<v[i];
// 		cout<<((i+1)%10?",\t":"\n");
// 	}
// 	cout<<"--\n";
// }

#define VMAX 100000
#define WMAX 1000000000
vector<int> dp(VMAX+1, WMAX+1);

int main(){
	int N,W; cin>>N>>W;
	dp[0] = 0;
	for(int i=1; i<=N; i++){
		int w,v; cin>>w>>v;
		for(int j=VMAX; j>=v; j--) dp[j] = min(dp[j], dp[j-v] + w);
	}
	// dpprn(dp,WMAX+1);

	int ans = 0;
	for(int i=1; i<=VMAX; i++) if(dp[i]<=W) ans = i;
	cout<< ans <<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

struct Node {
    int parent = -1, left = -1, right = -1;
};

int getSibling(int i, Node T[]) {
    Node t = T[i];
    if (t.parent == -1) {
        return -1;
    }
    Node p = T[t.parent];
    if (p.left == i) {
        return p.right;
    } else {
        return p.left;
    }
}

int getDegree(int i, Node T[]) {
    Node t = T[i];
    int d = 0;
    if (t.left != -1) {
        d++;
    }
    if (t.right != -1) {
        d++;
    }
    return d;
}

int getDepth(int i, Node T[]) {
    Node n = T[i];
    int d = 0;
    while (n.parent != -1) {
        d++;
        n = T[n.parent];
    }
    return d;
}

int getHeight(int h, int i, Node T[]) {
    Node c = T[i];
    int l = h, r = h;
    if (c.left != -1) {
        l = getHeight(h + 1, c.left, T);
    }
    if (c.right != -1) {
        r = getHeight(h + 1, c.right, T);
    }
    return max(l, r);
}

string getType(int i, Node T[]) {
    Node t = T[i];
    if (t.parent == -1) {
        return "root";
    }
    if (t.left == -1 && t.right == -1) {
        return "leaf";
    }
    return "internal node";
}

void printNodeInfo(int i, Node T[]) {
    Node c = T[i];
    cout << "node " << i << ": "
    << "parent = " << c.parent << ", "
    << "sibling = " << getSibling(i, T) << ", "
    << "degree = " << getDegree(i, T) << ", "
    << "depth = " << getDepth(i, T) << ", "
    << "height = " << getHeight(0, i, T) << ", "
    << getType(i, T) << endl;
}

int main() {
    int n;
    cin >> n;
    Node T[n];
    for (int i = 0; i < n; i++) {
        int id, l, r;
        cin >> id >> l >> r;
        T[id].left = l;
        T[id].right = r;
        T[l].parent = id;
        T[r].parent = id;
    }

    for (int i = 0; i < n; i++) {
        printNodeInfo(i, T);
    }

    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

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

int main()
{

    double N,K;
    cin>>N>>K;

    cout<<fixed;
    cout<<setprecision(12);

    double ans = 0;

    for(int i=1;i<=N;i++){
        double m=i;
        double sum = 1/N;
        while(m<=K-1){
            sum*=0.5;
            m*=2;
        }

        ans+=sum;
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;
const double PI = acos(-1);

int32_t main() {
    fastIO();
    
    int a, b;
    cin >> a >> b;
    cout << (a*b & 1 ? "Yes" : "No") << "\n";
    
    return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
int x,y,z;
for(;;){
scanf("%d %d %d",&x,&y,&z);
if(x+y+z==-3)break;
if(x==-1||y==-1)printf("F\n");
else if(x+y>=80)printf("A\n");
else if(x+y>=65)printf("B\n");
else if(x+y>=50)printf("C\n");
else if(x+y>=30){
if(z>=50)printf("C\n");
else printf("D\n");
}
else printf("F\n");
}
return 0;
}

Measured memory_bytes: 2596
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner (System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long max;
		if (a>=b)max=a;
		else max=b;
		long ans;
		for(ans=max;ans<=a*b;ans+=max) {
			if (ans%a==0&&ans%b==0)break;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	string s;
	cin >> s;
	int n = s.size();
	string r = s;
	reverse(s.begin(), s.end());

	bool ans = true;

	ans &= (r == s);

	string fr = s.substr(0, n / 2);
	string fr2 = fr;
	reverse(fr2.begin(), fr2.end());
	ans &= (fr == fr2);

	string af = s.substr(n / 2 + 1, n / 2);
	string af2 = af;
	reverse(af2.begin(), af2.end());
	ans &= (af == af2);

	if (ans) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}




	return 0;
}



Measured memory_bytes: 256
def main():
    n = int(input())
    rate_count = [0] * 13
    a = tuple(map(int, input().split()))
    for ae in a:
        rank = ae // 400
        rate_count[rank] += 1

    reds = sum(rate_count[8:])
    res = 0
    for i1 in range(8):
        res += rate_count[i1] > 0
    r_min = max(res, 1)
    r_max = res + reds
    print(r_min, r_max)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cout << v << " ";  \
  }                    \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int a[1010][1010];
int nowd[1010];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  //  vec<vec<int>> a(N, vec<int>(N - 1));
  //  vec<int> nowd(N, 0);
  REP(i, N) {
    REP(j, N - 1) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  int ans = 0;
  int count = 0;

  while (count != N * (N - 1)) {
    bool flg = false;
    //    bool flgI[1010];
    //   fill(flgI, flgI + N, false);
    vec<bool> flgI(N, false);
    REP(i, N) {
      // DEBUG(nowd[i]);
      if (flgI[i]) continue;
      if (nowd[i] >= N - 1) continue;
      int j = a[i][nowd[i]];
      if (flgI[j]) continue;
      if (nowd[j] >= N - 1) continue;
      int k = a[j][nowd[j]];
      if (i == k) {
        // DEBUG(ans);
        // DEBUG(count);
        // DEBUG(i);
        // DEBUG(j);

        flgI[i] = true;
        flgI[j] = true;
        flg = true;
        count += 2;
        nowd[i]++;
        nowd[j]++;
      }
    }
    if (!flg) {
      print("-1");
      return 0;
    }
    ans++;
  }
  print(ans);
}

Measured memory_bytes: 8192
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int a[3], b[3];
    int c1=0, c2=0, c3=0, c4=0;
    REP(i,3){
        cin >> a[i] >> b[i];
        switch(a[i]){
            case 1:
                c1++;
                break;
            case 2:
                c2++;
                break;
            case 3:
                c3++;
                break;
            case 4:
                c4++;
                break;
        }
        switch(b[i]){
            case 1:
                c1++;
                break;
            case 2:
                c2++;
                break;
            case 3:
                c3++;
                break;
            case 4:
                c4++;
                break;
        }
    }
    if(c1 >= 3 || c2 >= 3 || c3 >= 3 || c4 >= 3) cout << "NO" << endl;
    else cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int a[100006];
int main()
{
    int n,m;
    cin>>m>>n;
    for(int i=1;i<=n;i++)
      {
       cin>>a[i];
        m -=a[i];}
    if(m<=0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

const int MX = 2e5 + 5;
int N;
ll mem[MX][16];
vi A;

ll dp(int idx, int x) {
	if (idx == 1)
		return x;
	if (x >= 16)
		return dp(idx, 15) + (x - 15) * idx;
	ll& ret = mem[idx][x];

	if (ret != -1)
		return ret;
	ll currValue = A[idx] * (1LL << (x << 1));

	for (int i = 0;; ++i)
		if (A[idx - 1] * (1LL << (i << 1)) >= currValue)
			return ret = x + dp(idx - 1, i);
}

int main() {
	#ifdef LOCAL
	auto stTime = clock();
	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

//	ll x = 1e9;
//
//	cout << x * (1 << 30) << '\n';
//	cout << 4 * x * (1 << 30) << '\n';

	cin >> N;

	A.assign(N + 1, 0);

	for (int i = 1; i <= N; ++i)
		cin >> A[i];


	V<ll> pref(N + 1);

	for (int i = 0; i < MX; ++i) {
		for (int j = 0; j < 16; ++j) {
			mem[i][j] = -1;
		}
	}

	for (int i = 1; i <= N; ++i)
		pref[i] = dp(i, 0);

	V<ll> suff(N + 1);

	reverse(A.begin() + 1, A.end());

	for (int i = 0; i < MX; ++i) {
		for (int j = 0; j < 16; ++j) {
			mem[i][j] = -1;
		}
	}

	for (int i = 1; i <= N; ++i)
		suff[i] = dp(i, 0);

	ll ans = min(N + pref[N] * 2, suff[N] * 2);

	for (int i = 1; i <= N - 1; ++i)
		ans = min(ans, i + pref[i] * 2 + suff[N - i] * 2);

	cout << ans << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 33264
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout << max(a*b,c*d) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,t,c1,t1,min=1001;
	scanf("%d%d",&n,&t);
	for(i+0;i<n;i++){
		scanf("%d%d",&c1,&t1);
		if(t1<=t && c1<min)
			min=c1;
	}
	if(min==1001)
		printf("TLE");
	else
		printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 100010
using namespace std;
typedef long long ll;
string s;
ll d[N][3];
const ll M=1e9+7;
ll pw(ll a,ll b){
    if(b<0) return 0;
    ll ans=1;
    while(b){
        if(b%2) ans=ans*a%M;
        b/=2;
        a=a*a%M;
    }
    return ans;
}
int main(){
    cin>>s;
    int n=s.size();
    int cur=0;
    if(s[0]=='A' || s[0]=='?') d[0][0]=1;
    if(s[0]=='?') cur++;
    for(int i=1;i<n;i++){
         if(s[i]=='?'){

                d[i][0]=d[i-1][0]*3%M;d[i][1]=d[i-1][1]*3%M;d[i][2]=d[i-1][2]*3%M;
            d[i][0]=(d[i][0]+pw(3,cur))%M;
    d[i][1]=(d[i][1]+d[i-1][0])%M;
    d[i][2]=(d[i-1][1]+d[i][2])%M;
    cur++;
        }
    else {
        d[i][0]=d[i-1][0];d[i][1]=d[i-1][1];d[i][2]=d[i-1][2];
        if(s[i]=='A'){
            d[i][0]=(d[i][0]+pw(3,cur))%M;
        }
        if(s[i]=='B'){
            d[i][1]=(d[i][1]+d[i-1][0])%M;
        }
        if(s[i]=='C'){
            d[i][2]=(d[i-1][1]+d[i][2])%M;
        }
    }

    }
    printf("%lld\n",d[n-1][2]);
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
	return !b ? a : gcd(b, a % b);
}

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

	long long ans = 0;

	for(int i = 1; i <= k; ++i) {
		for(int j = 1; j <= k; ++j) {
			int t = gcd(i, j);
			for(int x = 1; x <= k; ++x) {
				ans += gcd(t, x);
			}
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[3][3];
    int n;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> a[i][j];
        }
    }
    cin >> n;
    int b[n];
    for( int k=0; k<n; k++){
        cin >> b[k];
        for( int i=0; i<3; i++){
            for( int j=0; j<3; j++){
                if(b[k]==a[i][j]){
                    a[i][j] = 0;
                }
            }
        }
    }

    // for j
    for( int j=0; j<3; j++){
        if( a[0][j] == 0 && a[1][j] == 0 && a[2][j] == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    // for i
    for( int i=0; i<3; i++){
        if(a[i][0]==0 && a[i][1]==0 && a[i][2]==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    // cross
    if(a[0][0]==0 && a[1][1]==0 && a[2][2]==0){
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][2]==0 && a[1][1]==0 && a[2][0]==0){
        cout << "Yes" << endl;
        return 0;
    }

    // no
    cout << "No" << endl;

}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  sort(all(A));
  rep(i,N-1){
    if(A[i]==A[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1792
#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 a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a) cout << k << endl;
  else if(k<=a+b) cout << a << endl;
  else cout << a-(k-a-b) << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll x;
  cin >> x;
  ll ans=0;
  ans+=x/11*2;
  x%=11;
  ans+=(x+5)/6;
  cout << ans << endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  int data[11][11];
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    memset(data, 0, sizeof(int) * 11 * 11);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        cin >> data[i][j];

    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        data[n][i] += data[j][i];
    for (int i = 0; i < n+1; i++)
      for (int j = 0; j < n; j++)
        data[i][n] += data[i][j];

    for (int i = 0; i < n+1; i++) {
      for (int j = 0; j < n+1; j++)
        printf("%5d", data[i][j]);
      printf("\n");
    }
  }
  return 0;
}

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

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

using namespace std;

int main()
{
	double ans=0.0;
	int n,k,t,u,v,l, time=0, carrot=0;
	cin >> n >> k >> t >> u >> v >> l;
	set<int> d;
	rep(i, n){
		int temp;
		cin >> temp;
		d.insert(temp);
	}
	rep(i, l){
		if (d.count(i)){
			if (carrot < k){
				carrot++;
			}else{
				time = v*t;
			}
		}
		if (time == 0 && carrot > 0){
			carrot--;
			time = v*t;
		}
		if (time > 0){
			time--;
			ans += 1.0/v;
		}else{
			ans += 1.0/u;
		}
	}
	cout << setprecision(9) << fixed << ans << endl;
	return 0;
}


Measured memory_bytes: 3288
#include <stdio.h>
int main(){
    int N,K;
    scanf("%d%d", &N,&K);
    int sum;
    for(int i=1;i<=N;i++){
        if(i==1)
            sum=K;
        else
            sum=sum*(K-1);
    }
    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class arc091_b {
public:
    void solve(istream& in, ostream& out) {
        int N, K;
        in >> N >> K;
        long long res = 0;
        for (int b = K + 1; b <= N; ++b) {
            for (int a = max(K, 1); a <= N; a += b) {
                if (a + b - K <= N)
                    res += b - K;
                else
                    res += N - a + 1;
            }
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc091_b solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

vector<pair<ll, ll>> xy(100);
int main(){

    int n;
    cin >> n;
    xy.resize(n);
    rep(i, n){
        cin >> xy[i].first >> xy[i].second;
    }
    sort(xy.begin(), xy.end());

    map<pair<int, int>, int> cnt;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            cnt[make_pair(xy[i].first-xy[j].first, xy[i].second-xy[j].second)]++;
        }
    }

    ll mx = 0ll;
    for(auto c : cnt){
        if(c.second > mx){
            mx = c.second;
        }
    }

    ppp(n-mx);


    return 0;
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast
    ll n, m;
    cin >> n >> m;
    vector<string> mat(n);
    REP(i, 0, n)
        cin >> mat[i];
    vvi dp(n, vi(m, 0));
    dp[0][0] = 1;
    REP(i, 1, n)
        if (mat[i][0] != '#')
            dp[i][0] = dp[i-1][0];
    REP(i, 1, m)
        if (mat[0][i] != '#')
            dp[0][i] = dp[0][i-1];
    REP(i, 1, n)
        REP(j, 1, m)
            if (mat[i][j] != '#')
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%M;
    cout << dp[n-1][m-1] << endl;
    return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int box[21];
	int q;
	int m;
	int dp[21][2001]={0};
	int i,j;
	
	cin>>n;
	for(i=0;i<n;i++)	cin>>box[i];
	dp[0][0]=1;
	for(i=0;i<n;i++){
		for(j=0;j<2001;j++){
			if(j+box[i]<=2000){
				if(dp[i][j]==1){
					dp[i+1][j]=dp[i][j];
					dp[i+1][j+box[i]]=1;
				}
			}
		}
	}
	cin>>q;
	for(i=0;i<q;i++){
		cin>>m;
		cout<<((dp[n][m])?"yes":"no")<<endl;
	}
	
	return 0;
}
				


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

int main()
{
    int n,ans=0;
    string s;
    cin>>s;
    int len=s.length();
    int temp=0;
    for(int i = 0;i<len;i++)
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
            temp++;
        else
            temp=0;
        if(temp>ans)
            ans=temp;
        
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 250
 
int main ()
{
  int i,num,A[MAX+1];
 
  scanf("%d",&num);
 
  for(i=1;i<=num;i++)
    {
      scanf("%d",&A[i]);
    }
 
  for(i=1;i<=num;i++)
    {
      printf("node %d: key = %d, ", i, A[i]);
     
      if(i/2 >= 1)
    {
      printf("parent key = %d, ", A[i/2]);
    }
      if(i*2 <= num)
    {
      printf("left key = %d, ", A[i*2]);
    }
      if((i*2)+1 <= num)
    {
      printf("right key = %d, ", A[(i*2)+1]);
    }
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;



int wa(int n) {

	int result = 0;

	while (n > 0) {
		result += n % 10;
		n /= 10;
	}

	return result;


}


int main()
{
    
	string str;
	cin >> str;

	if (str[2] == str[3] && str[4] == str[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;

}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 500007

struct Point {
  int x, y, i;
};

int n;
Point p[N];

bool comp_x(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool comp_y(const Point &p1, const Point &p2) { return p1.y < p2.y; }

struct Node {
  Node *left, *right;
  Point p;

  Node(Node *left, Node *right, Point p) : left(left), right(right), p(p) {}
};

Node *root;

Node* make(int l, int r, int depth) {
  if(!(l < r)) {
    return nullptr;
  }

  int mid = (l + r) >> 1;
  if(depth % 2) {
    sort(p + l, p + r, comp_x);
  } else {
    sort(p + l, p + r, comp_y);
  }

  return new Node(make(l, mid, depth+1), make(mid+1, r, depth+1), p[mid]);
}

void find(Node *nd, vector<int> &result,int sx, int tx, int sy, int ty, int depth) {
  Point &p = nd->p;
  if(sx <= p.x && p.x <= tx && sy <= p.y && p.y <= ty) {
    result.push_back(p.i);
  }

  if(depth % 2) {
    if(nd->left != nullptr && sx <= p.x) {
      find(nd->left, result, sx, tx, sy, ty, depth+1);
    }
    if(nd->right != nullptr && p.x <= tx) {
      find(nd->right, result, sx, tx, sy, ty, depth+1);
    }
  } else {
    if(nd->left != nullptr && sy <= p.y) {
      find(nd->left, result, sx, tx, sy, ty, depth+1);
    }
    if(nd->right != nullptr && p.y <= ty) {
      find(nd->right, result, sx, tx, sy, ty, depth+1);
    }
  }
}

int main() {
  scanf("%d", &n);
  rep(i, n) {
    scanf("%d %d", &p[i].x, &p[i].y);
    p[i].i = i;
  }
  root = make(0, n, 0);

  int q;
  cin >> q;
  rep(i, q) {
    int sx, tx, sy, ty; cin >> sx >> tx >> sy >> ty;
    vector<int> result;
    find(root, result, sx, tx, sy, ty, 0);
    sort(ALL(result));
    repe(v, result) {
      printf("%d\n", v);
    }
    printf("\n");
  }

  return 0;
}


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

std::map <long long, int> M;
int main(){
    FILE*fi,*fo;
    //fi = fopen("a.in","r");
    //fo = fopen("a.out","w");
    fi = stdin;
    fo = stdout;

    long long n;
    fscanf(fi,"%lld", &n);
    long long s = 0, ans = 0;
    M[0]++;
    for(int i = 1; i <= n; i++){
        long long x;
        fscanf(fi,"%lld", &x);
        s += x;
        ans += M[s];
        M[s]++;
    }
    fprintf(fo,"%lld", ans);

    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;

using namespace std;

int solve(string op, int a, int b)
{
    if(op == "+") {
        return a+b;
    } else if(op == "-") {
        return a-b;
    } else {
        return INF;
    }
}

int main() 
{
    v_string op = {"+", "-"};
    string s; cin >> s;
    v_int t(4);
    irep(i, 4) { 
        char tmp = s[i];
        t[i] = atoi(&tmp); 
    }

    irep(i, 2) {
        int a = solve(op[i], t[0], t[1]);  
        irep(j, 2) {
            int b = solve(op[j], a, t[2]);
            irep(k, 2) {
                int c = solve(op[k], b, t[3]);
                if(c == 7) { 
                    cout << s[0] << op[i] << s[1] << op[j] << s[2] << op[k] << s[3] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}
    



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int phy,cem,bio,tigaku,hys,tiri,x;

  scanf("%d",&phy);
  scanf("%d",&cem);
  scanf("%d",&bio);
  scanf("%d",&tigaku);
  scanf("%d",&hys);
  scanf("%d",&tiri);

  if(phy<cem){
    x=cem;
    cem=phy;
    phy=x;
  }

  if(cem<bio){
    x=bio;
    bio=cem;
    cem=x;
  }

  if(bio<tigaku){
    x=tigaku;
    tigaku=bio;
    bio=x;
  }

  if(hys<tiri){
    x=tiri;
    tiri=hys;
    hys=x;
  }

  printf("%d\n",phy+cem+bio+hys);

  return 0;
}

Measured memory_bytes: 600
n = int(input())

ans = 0
ans1 = [0] * 10050
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      ans = i**2 + j**2 +k**2 + i*j + j*k + k*i
      if(ans < 10050):
        ans1[ans] += 1
for i in range(n):
  print(ans1[i+1])


Measured memory_bytes: 73476