akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int n;
    cin >> n;
    int a = (n+1)/2;
    double aa = a;
    double bb = n;
    cout << setprecision(20) << aa/bb << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
class Program {
	static void Main() {
		int n = int.Parse(Console.ReadLine());
		int m = int.Parse(Console.ReadLine());
		int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] c = new int[n];
		for(int i = 0; i < m; i++) {
			int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
			for(int j = 0; j < n; j++) {
				if(a[i] == b[j]) c[j]++;
				else c[a[i] - 1]++;
			}
		}
		for(int i = 0; i < n; i++) {
			Console.WriteLine(c[i]);
		}
	}
}

Measured memory_bytes: 9756
def argmin(arg1, arg2):
    if H[arg1] > H[arg2]:
        return arg2
    elif H[arg1] < H[arg2]:
        return arg1
    else:
        return -1

N, M = list(map(int,input().split()))
H = list(map(int,input().split()))
A = []
B = []
for i in range(M):
    a, b = list(map(int,input().split()))
    A.append(a - 1)
    B.append(b - 1)
    
ans = [0 for _ in range(N)]

for i in range(M):
    ret = argmin(A[i], B[i])
    if ret != -1:
        ans[ret] = -1
    else:
        ans[A[i]] = -1
        ans[B[i]] = -1
        
print(ans.count(0))

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N, K;
ll H[200050];
bool ok[200050];
int out[200050];

int main(){
    cin >> N >> K;
    FOR(i,1,N+1)cin >> H[i];
    sort(H+1,H+N+1,greater<>());
    ll cnt=0;
    FOR(i,1,N+1)
    {
      if(K>0)
      {
        K--;
      }
      else
      {
        cnt+=H[i];
      }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int A, B; cin >> A >> B;
    int sum = A+B;
    sum%=24; sum+=24; sum%=24;
    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);//this works only
    cin.tie(NULL);// when first all inputs are from user
    cout.tie(NULL);//you will see all outputs afterwards
    ll n,a,b;
    cin>>n>>a>>b;
    ll dif=b-a;
    if(dif%2==0)
    {
    	cout<<dif/2;
    }
    else
    {
    	ll ans=0;
    	ll p1=a-1;
    	ll p2=n-b;
    	if(p2>p1)
    	{
    		ans=p1;
    		a=1;
    		b-=p1;
    		b--;
    		ans++;
    		ll dif1=(b-a);
    		ans+=dif/2;
    	}
    	else
    	{
 			ans=p2;
    		//a=1;
    		//b-=p2;
    		//b--;
    		a+=p2;
    		b=n;
    		a++;
    		ans++;
    		ll dif1=(b-a);
    		ans+=dif/2;   		
    	}
    	cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      int n;
      cin >> n;
      vll a;
      inl(a,n);
      vll res;
      int x=0;
      for(int i=0;i<n;i++){
            x ^= a[i];
      }

      int s=0;
      for(int i=0;i<n;i++){
            s = x ^ a[i];
            res.pb(s);
      }
      print(res);
      
}


Measured memory_bytes: 7804
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let uv: Vec<(usize, usize)> = (0..m).map(|_| (input(), input())).collect();
    let s: usize = input();
    let t: usize = input();

    let mut e = vec![vec![]; n];
    for (u, v) in uv {
        e[u - 1].push(v - 1);
    }

    let s = s - 1;
    let t = t - 1;

    let mut dist = vec![vec![-1; 3]; n];
    let mut q = std::collections::VecDeque::new();
    q.push_back((s, 0, 0));
    while let Some((cur, k, d)) = q.pop_front() {
        if dist[cur][k] >= 0 {
            continue;
        }

        dist[cur][k] = d;
        if cur == t && k == 0 {
            break;
        }

        let k = (k + 1) % 3;
        for &next in &e[cur] {
            if dist[next][k] < 0 {
                q.push_back((next, k, d + 1));
            }
        }
    }

    println!("{}", if dist[t][0] >= 0 { dist[t][0] / 3 } else { -1 });
}


Measured memory_bytes: 16636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

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

  vector<int> previous(3, 0);
  for (int i = 0; i < n; i++) {
    vector<int> next(3, 0);
    for (int j = 0; j < 3; j++) {
      int e;
      cin >> e;

      for (int k = 0; k < 3; k++) {
        if (k == j) continue;
        next[j] = max(next[j], previous[k] + e);
      }
    }

    previous = next;
  }

  cout << *max_element(begin(previous), end(previous)) << endl;
  return 0;
}


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

int main() {
  int n, l; cin >> n >> l;
  vector<int> apple(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    apple.at(i) = i + l;
    sum += apple.at(i);
  }
  int min_diff = 1e+9, ans;
  for (int i = 0; i < n; i++) {
    int diff = abs(apple.at(i));
    if (diff < min_diff) {
      min_diff = diff;
      ans = sum - apple.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        var C = cin.nextlong;
        var X = new long[N];
        var V = new long[N];
        var R = new long[N];
        var L = new long[N];
        var VR = new long[N];
        var VL = new long[N];
        var memoR = new long[N];
        var memoL = new long[N];
        for (int i = 0; i < N; i++)
        {
            X[i] = cin.nextlong;
            V[i] = cin.nextlong;
        }

        for (int i = 0; i < N; i++)
        {
            VR[i] = V[i] + VR[Max(0, i - 1)];
            R[i] = -X[i] + VR[i];

            memoR[i] = Max(memoR[Max(0, i - 1)], -X[i] * 2 + VR[i]);
        }


        for (int u = 0; u < N; u++)
        {
            int i = N - u - 1;
            VL[i] = V[i] + VL[Min(N - 1, i + 1)];
            L[i] = -(C - X[i]) + VL[i];

            memoL[i] = Max(memoL[Min(N - 1, i + 1)], -(C - X[i]) * 2 + VL[i]);
        }

        long ans = 0;
        
        for (int i = 0; i < N; i++)
        {
            ans = Max(ans, R[i]);
            ans = Max(ans, L[i]);
            if (i < N - 1) ans = Max(ans, R[i] + memoL[i + 1]);
            if (i > 0) ans = Max(ans, L[i] + memoR[i - 1]);
        }

        WriteLine(ans);

    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 23392
import java.util.*;
import java.lang.Math;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] x = new int[n];
        for(int i=0; i<n; i++){
            x[i] = sc.nextInt();
        }        
        int ans = Integer.MAX_VALUE;
        int sumr = 0;
        int suml = 0;
        
        for(int i=0; i<n-k+1; i++){ 
            sumr = Math.abs(x[i])+Math.abs(x[i+k-1]-x[i]);
            suml = Math.abs(x[i+k-1])+Math.abs(x[i+k-1]-x[i]);
            ans = Math.min(ans, Math.min(sumr, suml));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 52328
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str = br.readLine();
      int x = Integer.parseInt(str);

      //System.out.println( x^3 ); // ^???Java??§???????????§?????????XOR???????????????
      System.out.println( x*x*x );
      //System.out.println( Math.pow(x,3) );
      //System.out.println( (int)Math.pow(x,3) );

   }
}

Measured memory_bytes: 24308
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<cmath>
#include<stack>
#include<string>

using namespace std;

int main() {
	vector<char> str;
	string s;
	cin >> s;
	str = vector<char>(s.length());
	int cnt = 0;
	for (char c : s) {
		if (cnt == 0) str[cnt++] = c;
		else if (str[cnt - 1] == 'S' && c == 'T') {
			cnt--;
		}
		else str[cnt++] = c;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int x, y, z;

    cin >> x >> y >> z;

    cout << z << " " << x << " " << y;
}

Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a < b) {
			System.out.println("a < b");
		}else if (a > b) {
			System.out.println("a > b");
		}else {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26052
class Otoshidama
  def initialize(n, y)
    @n = n
    @b10000 = 0
    @b5000 = 0
    @b1000 = y / 1000
  end

  def calc
    # 1000 => 10000 で9枚、1000 => 5000 で4枚減らせる
    # 9か4を引く操作をn回以内でしたとき、計枚数がnになれば可能
    redundant = @b1000 - @n
    @n.times do
      if redundant < 4
        break
      elsif redundant % 9 == 0 && 10 * (redundant / 9) <= @b1000
        numOf10000 = redundant / 9
        @b10000 += numOf10000
        @b1000 -= 10 * numOf10000
        break
      else
        redundant -= 4
        @b5000 += 1
        @b1000 -= 5
      end  
    end

    setDummyAnswer if @b10000 + @b5000 + @b1000 != @n
  end

  def setDummyAnswer
    @b10000 = -1
    @b5000 = -1
    @b1000 = -1
  end

  def answer
    puts "#{@b10000} #{@b5000} #{@b1000}"
  end
end

N, Y = gets.chomp.split(" ").map(&:to_i)
otoshidama = Otoshidama.new(N, Y)
otoshidama.calc
otoshidama.answer


Measured memory_bytes: 1788
#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 x,y;
    cin >> x >> y;
    int turu,kame;
    rep(i,x+1){
        turu = i;
        kame = x - i;
        if(2*turu + 4*kame == y){
            cout << "Yes" <<endl;
            return 0 ;
        }
    }
    cout << "No"  << endl;
    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;

  int ans = a;

  if(a > b) ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 5000 + 10;
int p[MAXN], c[MAXN];
bool used[MAXN];
vector<LL> nums;
LL sum;

LL dfs(int i, LL k) {
  used[i] = true;
  nums.push_back(c[i]);
  sum += c[i];
  if (used[p[i]]) {
    LL n = nums.size();
    LL ret = LLONG_MIN;
    if (k >= n) ret = max(ret, k/n*sum);
    for (int len = 1; len < n; len++) {
      if (len > k) break;
      LL tmp = 0;
      for (int i = 0; i < len; i++) {
        tmp += nums[i];
      }
      for (int i = 0; i < n; i++) {
        tmp -= nums[i];
        tmp += nums[(i+len)%n];
        ret = max(ret, tmp);
        ret = max(ret, tmp + sum*((k-len)/n));
      }
    }
    return ret;
  }
  return dfs(p[i], k);
}





int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n, k; cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  LL ret = LLONG_MIN;
  for (int i = 1; i <= n; i++) {
    if (used[i]) continue;
    nums.clear();
    sum = 0;
    ret = max(dfs(i, k), ret);
  }
  cout << ret << '\n';






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 3264
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	vll p(100010,1) ;
	p.at(0) = p.at(1) = 0 ;
	for(int i=2;i<p.size();i++){
		if(p.at(i)){
			for(int j=i*2;j<p.size();j+=i) p.at(j) = 0 ;
		}
	}
	vll sum(100010,0) ;
	for(int i=2;i<sum.size();i++){
		sum.at(i) = sum.at(i-1) ;
		if(p.at(i)&&p.at((i+1)/2)) sum.at(i)++ ;
	}
	ll q ; cin >> q ;
	for(int i=0;i<q;i++){
		ll l,r ;
		cin >> l >> r ;
		cout << sum.at(r)-sum.at(l-1) << endl ;
	}
}


Measured memory_bytes: 2176
n=int(input())
l=list(map(int,input().split()))
if len(set(l))==1:print(n//2)
else:
  x,y=sorted(l[::2]),sorted(l[1::2])
  from collections import Counter as co
  ans=0
  mx,my=co(x).most_common(100),co(y).most_common(100)
  for i in mx:
    for j in my:
      k=i[1]+j[1] if i[0]!=j[0] else 0
      ans=max(ans,k)
  print(n-ans)


Measured memory_bytes: 15988
#include<stdio.h>

int gcd(int a, int b) {
  int r;
  while(b > 0){
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

  
int main() {
  int x, y, i, k;
  scanf("%d %d", &x, &y);
  if(x > y) k = gcd(y, x);
  else k = gcd(x, y);
  printf("%d\n", k);
  return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int x[100005], l[100005], dp[200005], pref[200005];
vector<int> interval[200005];

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

    int n;
    cin >> n;
    map<int, int> compress;
    for (int i=0; i<n; i++) {
        cin >> x[i] >> l[i];
        compress[x[i] - l[i]];
        compress[x[i] + l[i]];
    }

    int idx = 1;
    for (auto &p : compress)
        p.second = idx++;
    for (int i=0; i<n; i++)
        interval[compress[x[i] + l[i]]].push_back(compress[x[i] - l[i]]);

    for (int i=1; i<idx; i++) {
        // delete all intervals
        dp[i] = dp[i-1];
        // keep one of the intervals
        for (int j : interval[i])
            dp[i] = max(dp[i], dp[j] + 1);
    }
    cout << dp[idx-1] << "\n";

    return 0;
}


Measured memory_bytes: 22312
#include <bits/stdc++.h>
using namespace std;
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstdlib>





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



  vector<int> ans(N, 0);

  int i=1;
  int j=1;
  int k=1;

  // int ans = 0;

  for (int n=1; n<N+1; n++)
  {
    while(i*i + i + 4 <= n)
    {
      while(i*i + i + j*j + j + i*j + 1 <= n)
      {
        while(k<n)
        {
          if (i*i + j*j + k*k + i*j + j*k + k*i == n)
          {
            ans.at(n-1)++;
            // cout << n << endl;
          }
          else if (i*i + j*j + k*k + i*j + j*k + k*i > n)
          {
            break;
          }
          k++;
        }
        k = 1;
        j++;
      }
      j = 1;
      k = 1;
      i++;
    }

    j = 1;
    k = 1;
    i = 1;
  }

  for (int l=0; l<N; l++)
  {
    cout << ans.at(l) << endl;
  }

  // cout << ans.at(0) << endl;
  // cout << ans.at(1) << endl;


  return 0;


}


Measured memory_bytes: 3632
import Foundation
 
let array = readLine()!.componentsSeparatedByString(" ")
let numOfPoints = Int(array[0])!
let dimension = Int(array[1])!
var points: [[Int]] = [[Int]]()
var countInt = 0
 
for i in 0...numOfPoints-1 {
  let array = readLine()!.componentsSeparatedByString(" ")
  var tmpIntArray: [Int] = [Int]()
  for elem in array {
    tmpIntArray.append(Int(elem)!)
  }
  points.append(tmpIntArray)
}
 
for i in 0...numOfPoints-1 {
  for j in 0...numOfPoints-1 {
    if j <= i {
      continue
    }
    var distance = 0
    for (iElem, jElem) in zip(points[i], points[j]) {
      distance += (iElem - jElem) * (iElem - jElem)
    }
    for num in 1...127 {
      if distance == num * num {
        countInt += 1
        break
      }
    }
  }
}
 
print(countInt)

Measured memory_bytes: 1280
#include<stdio.h>
typedef struct{int Parent,Rank;}UnionFind;
static inline int Root(int x,UnionFind *uf)
{
  if(uf[x].Parent==x)return x;
  else return uf[x].Parent=Root(uf[x].Parent,uf);
}
static inline int Unite(int x,int y,UnionFind *uf)
{
  x=Root(x,uf),y=Root(y,uf);
  if(x==y)return 0;
  uf[x].Parent=y;uf[y].Rank+=uf[x].Rank;return 1;
}
static inline int Size(int x,UnionFind *uf){return uf[Root(x,uf)].Rank;}
static inline int Belong(int x,int y,UnionFind *uf){return Root(x,uf)==Root(y,uf);}
int main(void)
{
  int A,B,C,D,N,M,K;
  (void)scanf("%d %d %d",&N,&M,&K);
  int known[N];
  UnionFind uft[N];
  for(int i=0;i<N;i++){known[i]=0;uft[i].Parent=i;uft[i].Rank=1;}
  while(M--)
  {
    (void)scanf("%d %d",&A,&B);
    A--,B--;known[A]++,known[B]++;Unite(A,B,uft);
  }
  while(K--)
  {
    (void)scanf("%d %d",&C,&D);
    C--,D--;if(Belong(C,D,uft))known[C]++,known[D]++;
  }
  for(int i=0;i<N;i++){printf("%d ",Size(i,uft)-known[i]-1);}
  return printf("\n"),0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  rep(i, h) {
    rep(j, w) {
      if(s[i][j] == '#') {
        bool ok = false;
        rep(k, 4) {
          int ni = i+di[k], nj = j+dj[k];
          if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
          if(s[ni][nj] == '#') ok = true;
        }
        if(!ok) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
const long mod=1e9+7;
int main(){
	int a,b;cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl;
}

Measured memory_bytes: 256
n = int(input())
ans = ''
for i in range(1, 99):
    if n <= 26 ** i:
        n -= 1
        for _ in range(i):
            ans += chr(ord('a') + n % 26)
            n //= 26
        break
    else:
        n -= 26 ** i
print(ans[::-1])

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  ll N, M;
  cin >> N >> M;
  ll ans = 0;
  ans += min(N, M / 2);
  M -= ans * 2;
  ans += M / 4;
  cout << ans << endl;
}


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

int town[200050];
int rd[200050],rev[200050];
int cnt[200050][2];

int main(){
    ll n,k;
    scanf("%lld%lld",&n,&k);
    ll i,j,g=1;
    for(i=1;i<=n;i++) scanf("%d",&town[i]);
    i=1;
    while(1){
        rd[g++]=i;
        if(cnt[i][0]==0) cnt[i][0]=g-1;
        else{
            cnt[i][1]=g-1;
            break;
        }
        i=town[i];
    }
    g=1;
    for(j=cnt[i][0];j<=cnt[i][1];j++,g++) {rev[g]=rd[j];}
    rev[0]=rev[g-2];
    if(k<cnt[i][0]) printf("%d",rd[k+1]);
    else /*if(cnt[i][1]-cnt[i][0]>1)*/{
        printf("%d",rev[(k-(ll)cnt[i][0])%((ll)cnt[i][1]-(ll)cnt[i][0])+2]);
    }
    //else printf("%d",rd[cnt[i][0]]);
}



Measured memory_bytes: 7492
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	
	static int[][] map;
	
	static int calc(int sx, int sy, int tx, int ty)
	{
		Boolean ok = true;
		for(int x = sx;x <= tx;x++)
			for(int y = sy;y <= ty;y++)
			{
				if(map[y][x] == 0) ok = false;
			}
		
		if(ok)
			return (tx - sx + 1) * (ty - sy + 1);
		else
			return 0;
	}
	
	static void start()
	{
		int max = 0;
		
		for(int y = 0;y < 5;y++)
			for(int x = 0;x < 5;x++)
				for(int yy = y;yy < 5;yy++)
					for(int xx = x;xx < 5;xx++)
					{
						int tmp = calc(x, y, xx, yy);
						max = Math.max(max, tmp);
					}
		
		System.out.println(max);
	}
	
	public static void main(String[] args)
	{
		
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			int m = sca.nextInt();

			for(;m > 0;m--)
			{
				map = new int[5][5];
				for(int y = 0;y < 5;y++)
					for(int x = 0;x < 5;x++)
						map[y][x] = sca.nextInt();
				
				start();
			}
			
			break;
		}
	}
}

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

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 2e5+10;
                        
int a[maxn];

int main(void){

     #ifndef ONLINE_JUDGE
     freopen("in.txt", "r", stdin);
     freopen("out.txt", "w", stdout);
     #endif
    string s;
    cin >> s;
    int len = s.size();
    if(s[len-1]=='s') cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		string s[n];
		for(int i=0;i<n;i++)
			cin>>s[i];
		int a[n+1][n+1]={};
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++){
				if(s[i-1][j-1]=='.')
					a[i][j]=min(a[i-1][j-1],min(a[i-1][j],a[i][j-1]))+1;
				else
					a[i][j]=0;
			}
		int p=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				p=max(p,a[i+1][j+1]);
		cout<<p<<endl;
	}
}

Measured memory_bytes: 7972
v, e = map(int, input().split())
p = [[] for i in range(v)]
for i in range(e):
    s, t = list(map(int, input().split()))
    p[s].append(t)


def dfs(s):
    if visit[s] != 1:
        visit[s] = 1
        stack[s] = 1
        for t in p[s]:
            if stack[t] == 1:
                print("1")
                exit()
            else:
                dfs(t)
    stack[s] = 0


visit = [0] * v
stack = [0] * v
for i in range(v):
    dfs(i)
print("0")



Measured memory_bytes: 5608
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  char c;
  cin >> c;
  if (
    c == 'a' or
    c == 'i' or
    c == 'u' or
    c == 'e' or
    c == 'o'
  ) puts("vowel");
  else puts("consonant");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[][] f = new int[n][10];
		for(int i=0;i<n;i++) {
			for(int j=0;j<10;j++) {
				f[i][j] = in.nextInt();
			}
		}
		int[][] p = new int[n][11];
		for(int i=0;i<n;i++) {
			for(int j=0;j<=10;j++) {
				p[i][j] = in.nextInt();
			}
		}
		int max = Integer.MIN_VALUE;
		for(int i=1;i<=1023;i++) {
			int[] joisino = new int[10];
			for(int j=0;j<10;j++) {
				joisino[j] = (i>>j)&1;
			}
			int sum = 0;
			for(int j=0;j<n;j++) {
				int c = 0;
				for(int k=0;k<10;k++) {
					c += joisino[k] * f[j][k];
				}
				sum += p[j][c];
			}
			if(sum>max) max = sum;
		}
		System.out.println(max);
		in.close();

	}

}

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

int main(){

    int x;
    scanf("%d", &x);


    int num=0;
    for(int i=1; ; ++i){
        num=(i*(i+1))/2;
        if(num>=x){
            /*if(num==x){
                printf("%d\n", i);
                break;
            }
            else{
                int num2=num-i;
                //printf("%d\n%d\n%d\n", num, num2, i);
                printf("%d\n", min( ((x-num2)+(i-1)), ((i+1)+(num-x)) ) );
                break;
            }*/
            printf("%d", i);
            break;
        }
    }






    return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())

    L = []
    R = []
    for i in range(M):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)

    Lout = max(L)
    Rout = min(R)
    ans = Rout - Lout+1
    if ans < 0:
        print(0)
    else:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10992
def insertionSort(number, array)
  puts array.join(" ").strip

  for i in 1..number-1 do 
    next_array = array[i]
    j = i - 1

    while ( j >= 0 && array[j].to_i > next_array.to_i)
      array[j + 1] = array[j]
      array[j] = next_array
      j -= 1
    end
    puts array.join(" ").strip
  end
end

number = gets.to_i
array = gets.to_s.split(" ")

insertionSort(number,array)


Measured memory_bytes: 6884
#include <stdio.h>

int main(void) {
	int ans[16][128] = {0},i,j,k,sum,num,n,s;
	for(i = 0;i <= 1023;i++){
		k = i;
		j = 0;
		sum = 0;
		num = 0;
		while(k){
			if(k % 2){
				sum += j;
				num++;
			}
			j++;
			k = k / 2;
		}
		ans[num][sum]++;
	}
	while(scanf("%d%d",&n,&s) , n != 0){
		printf("%d\n",ans[n][s]);
	}
	return 0;
}

Measured memory_bytes: 604
import Control.Applicative
import Data.List
import Data.Ratio

main = do
  n <- readLn :: IO Int
  as <- scanl (+) 0 . map read . words <$> getLine :: IO [Int]

  print $ sum . map (((flip combination) 2) . length) . group . sort $ as

{-- nCk --}
combination :: Integral a => a -> a -> a
combination n k = numerator $ combination' n k
  where
    combination' :: Integral a => a -> a -> Ratio a
    combination' n k
      | n < k || n < 0 || k < 0 = 0
      | n == 0 || k == 0 = 1
      | otherwise = (n % k) * combination' (n-1) (k-1)


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back
#define eb emplace_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    vint p = in(n);
    int ma = INF;
    int cnt = 0;
    rep(i, n)
    {
        if (ma > p[i])
        {
            ++cnt;
            ma = p[i];
        }
    }
    cout << cnt << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {

 public static void main(String[] args) {
  Scanner no=new Scanner(System.in);
  int n=no.nextInt();
  int sum=0;
  int ans=0;
  int i=1;
  while(sum<n){
    ans++;
    sum=sum+i;
    i++;
  }
  System.out.println(ans);
 }

}


Measured memory_bytes: 35624
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  let a = [];
  let a_ = 1;
  let arr = new Array(n);
  for(let i=0; i<n; i++) {
    a[i] = parseInt(input[a_]);
    arr[i] = new Array(a[i]).fill({x:0,y:0});
    for(let j=0; j<a[i]; j++) {
      let p = input[a_+j+1].split(' ').map(val => parseInt(val));
      arr[i][j] = {x: p[0]-1, y: p[1]};
    }
    a_ += a[i]+1;
  }
  // console.log(a, arr);
  const toBinary = (s,n) => {
    let t = s.toString(2);
    while(t.length < n) {
      t = '0'+ t;
    }
    return t;
  }

  for(let i=Math.pow(2,n)-1; i>=0; i--) {
    let z = toBinary(i,n);
    let check = true;
    for(let j=0; j<n; j++) {
      arr[j].map(val => {
        if (z[j] == 1 && z[val.x] != val.y) {
          check = false;
        }
      })
    }
    if (check) {
      let ans = z.split('').filter(word => word == '1').length;
      // console.log(`^^^^^^${ans}`);
      // console.log(`${z}^^^^^^^^`);
      return console.log(ans)
    }
  }
  return console.log(0);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 10384
N,M = map(int,input().split())
E = []
for _ in range(M):
    E.append(list(map(int,input().split())))
G = {i:[i,1] for i in range(N+1)}
A = [(N*(N-1))//2]
for i in range(M-1,-1,-1):
    a,b = E[i][0],E[i][1]
    ar = G[a][0]
    br = G[b][0]
    while True:
        if ar==G[ar][0]:
            break
        else:
            ar = G[ar][0]
    while True:
        if br==G[br][0]:
            break
        else:
            br = G[br][0]
    if ar!=br:
        A.append(A[-1]-G[ar][1]*G[br][1])
        if G[ar][1]>=G[br][1]:
            G[ar][1] += G[br][1]
            G[br][0] = ar
        else:
            G[br][1] += G[ar][1]
            G[ar][0] = br
    else:
        A.append(A[-1])
for i in range(M-1,-1,-1):
    print(A[i])

Measured memory_bytes: 92116
#include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	ll w, h;
	cin >> w >> h;
	multimap<ll, ll> mm;
	rep(i, w) {
		int tmp;
		cin >> tmp;
		mm.insert({tmp, 0});
	}
	rep(i, h) {
		int tmp;
		cin >> tmp;
		mm.insert({tmp, 1});
	}

	ll ans = 0;
	for (auto x : mm) {
		if (x.second == 0) {
			ans += (h + 1) * x.first;
			w--;
		}
		else {
			ans += (w + 1) * x.first;
			h--;
		}
	}


	cout << ans << endl;
}




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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 13048
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long sut = 0;
const int typeNum = 26;
vector<vector<long long> > table;

long long last(long long d, long long i) {
    return table[i][d];
};

void solve(long long D, std::vector<long long> c, std::vector<std::vector<long long> > s, std::vector<long long> t){
    // make table
    for (int i=0;i<typeNum;++i) {
        table.push_back(vector<long long>(t.size()));

        for (int j=0;j<t.size(); ++j) {
            table[i][j] = -1;
        }
    }
 

    for (int i=0; i<t.size(); ++i) {
        vector<long long> &target = table[t[i] - 1];
        for (int j=i; j<target.size() ;++j) {
            target[j] = i;
        }
    }

    // for (int i=0; i<table.size(); ++i) {
    //     cout << i << '\t';
    //     for (int j=0; j<table[i].size(); ++j) {
    //         cout << table[i][j] << ',';
    //     }
    //     cout << endl;
    // }

    for (int d = 0; d < D; ++d) {
        sut += s[d][t[d] - 1];

        // minus
        for (int i=0;i<typeNum;++i) {
            sut -= c[i] * (d - last(d, i));
        }
        cout << sut << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
    scanf("%lld",&D);
    std::vector<long long> c(26);
    for(int i = 0 ; i < 26 ; i++){
        scanf("%lld",&c[i]);
    }
    std::vector<std::vector<long long> > s(D, std::vector<long long>(26));
    for(int i = 0 ; i < D ; i++){
        for(int j = 0 ; j < 26 ; j++){
            scanf("%lld",&s[i][j]);
        }
    }
    std::vector<long long> t(D);
    for(int i = 0 ; i < D ; i++){
        scanf("%lld",&t[i]);
    }
    solve(D, std::move(c), std::move(s), std::move(t));
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int l = S.size();
  ll sum = 0;
  for(int bit = 0; bit < (1<<l-1); bit++){
    string ss = "";//ここにSの1文字目から入れていく。
    for(int i = 0; i < l; i++){
      ss += S[i];
      if(bit & (1<<i)){//１が立っていたら、
        sum += stoll(ss);//その時点でのｓｓを足す。
        ss = "";//ｓｓを初期化。
      }
    }
    sum += stoll(ss);//＋処理後のｓｓを足す。
    ss = "";
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace AtCoder.ABC173
{
    public class Problem1
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var cnt = 1;

            var total = 0;

            while (total < N)
            {
                total += 1000;
                cnt++;
            }

            Console.WriteLine((total - N).ToString());
        }
    }
}


Measured memory_bytes: 27536
// ref: https://yamakasa.net/atcoder-abc-087-d/

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

struct edge{
    int to;
    int cost;
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, M; cin >> N >> M;
    vector<vector<edge>> vvGraph(N);
    for(int i=0; i<M; ++i){
        int L, R, D; cin >> L >> R >> D; --L; --R;
        vvGraph[ L ].push_back( edge{R, D} );
        vvGraph[ R ].push_back( edge{L,-D} );
    }
    
    vector<int> id2cost(N, INT_MAX);
    for(int n=0; n<N; ++n){
        if(id2cost[n]!=INT_MAX){ continue; }
        id2cost[n] = 0;              // cost
        queue<int> que; que.push(n); // index (from)
        while(que.size()!=0){
            int u = que.front(); que.pop(); // index (from)
            for(int i=0; i<(int)vvGraph[u].size(); ++i){
                int v    = vvGraph[u][i].to; // u to v
                int cost = vvGraph[u][i].cost;
                
                if(id2cost[v]==INT_MAX){
                    id2cost[v] = id2cost[u]+cost; // cost of u to v.
                    que.push( v );
                }else{
                    if(id2cost[v] != id2cost[u]+cost){ cout << "No" << endl; return 0; }
                }
            }
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 9344
import sys
from collections import deque
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    edge = [[] for _ in range(N)]
    
    for _ in range(M):
        a,b = map(int,input().split())
        a -= 1;b -= 1
        edge[a].append(b)
        edge[b].append(a)
        
    go = [False]*N
    go[0] = True
    bef = [-1]*N
    
    q = deque([0])
    while q:
        now = q.popleft()
        for fol in edge[now]:
            if not go[fol]:
                bef[fol] = now
                go[fol] = True
                q.append(fol)

    if False in go:
        print("No")
    else:
        print("Yes")
        for i in range(1,N):
            print(bef[i]+1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 90716
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, n, sum = 0;
  cin >> h >> n;
  REP(i,n) {
    int a;
    cin >> a;
    sum += a;
  }
  YesorNo(sum >= h);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256