akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

// define
# define loop(i,a,n) for(int i=a;i<n;++i)
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(0);
# define ll long long int 
# define endl "\n"
# define mp make_pair
# define mt make_tuple
# define pb push_back
# define eb emplace_back
# define in insert
# define rev(i,a,n) for(int i=n-1;i>=a;--i)
# define test int T; cin>>T; while(T--)
# define val 32

/* debug */ 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _itRS(_ss); err(_itRS, args); }

void err(istream_iterator<string> itRS) {}
template<typename T, typename... Args>
void err(istream_iterator<string> itRS, T a, Args... args) {
    cerr << *itRS << " = " << a << endl;
    err(++itRS, args...);
}
int dx[8] = {-1,-1,-1, 0, 0, 1, 1, 1}; 
int dy[8] = {-1, 0, 1,-1, 1,-1, 0, 1};


const int MOD=1000000007;



int main()
{   fast
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    while(k--)
    {
        if(b<=a)
        {
            b*=2;
        }
        else if(c<=b)
        {
            c*=2;
        }
    }
    if(c>b && b>a)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

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

signed main() {
    int n;cin>>n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<int> dp(n,0);
    dp[1] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int m, f, r;
	
	for(;;){
		scanf("%d %d %d", &m, &f, &r);
		if(m == -1 && f == -1 && r == -1){
			break;
		}
		
		if(m == -1 || f == -1){
			printf("F\n");
		}else if(m+f >= 80){
			printf("A\n");
		}else if(65 <= m+f && m+f < 80){
			printf("B\n");
		}else if(50 <= m+f && m+f < 65){
			printf("C\n");
		}else if(30 <= m+f && m+f < 50){
			if(r >= 50){
				printf("C\n");
			}else{
				printf("D\n");
			}
		}else{
			printf("F\n");
		}
	}
	
	return 0;
}


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

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

#define fi first
#define se second

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

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

int N;
string S;

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

  int w = 0;
  for (int i = 0; i < N; i++){
    if (S[i] == 'W') w++;
  }
  int ans = 0;
  for (int i = 0; i < w; i++){
    if (S[N - 1 - i] == 'R') ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3724
x=int(input())
import math
for i in range(x, 10**5+100000):
  flag=True
  e = math.floor(math.sqrt(x))
  for j in range(2, e+1):
    if i%j == 0:
      flag=False
      break
  if flag==True:
    print(i)
    exit()

Measured memory_bytes: 3064
import string

# 1千兆 + 1
N = int(input())
n_digits = len(str(1000000000000001))
letters = string.ascii_lowercase

# x = N - 1
x = N
ans = []
# while True:
#     x -= 1
#     mod = x % 26
#     ans = [ mod ] + ans
#     x = x // 26
#     if x <= 0:
#         break

# print(ans)
# print("".join([ letters[v] for v in ans ]))

while True:
    x -= 1
    mod = x % 26
    # div = x // 26
    x = x // 26
    
    ans.append(mod)
    # if div == 0:
    if x == 0:
        break
    # x = div - 1

ans = ans[::-1]
print("".join([ letters[v] for v in ans ]))

Measured memory_bytes: 9892
import numpy as np
N = int(input())
A_list = list(map(int, input().split()))

dp = np.zeros((len(A_list)+1, 2))
dp[0][1] = - 10**5

for idx, a in enumerate(A_list):
    dp[idx+1][0] = max(dp[idx][0] + a, dp[idx][1] - a)
    dp[idx+1][1] = max(dp[idx][0] - a, dp[idx][1] + a)
print(int(dp[N][0]))

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

int main(void){

  int H,W;
  while(cin >> H >> W){
    if(H == 0 && W == 0) break;
    int i,j;
    for(i=0; i<H; i++){
      for(j=0; j<W; j++){
	if(i%2 == 1){
	  if(j%2 == 1) cout << "#";
	  else cout << ".";
	}else{
	  if(j%2 == 1) cout << ".";
	  else cout << "#";
	}
      }
      cout << endl;
    }
    cout << endl;
  }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,a[2005];
bitset<4000005>b;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    ll s=0;
    rep(i,0,n)
        cin>>a[i],s+=a[i];
    b[0]=1;
    rep(i,0,n)
        b|=(b<<a[i]);
    rep(i,(s+1)/2,4000005)
    {
        if(b[i])
        {
            cout<<i<<"\n";
            return 0;
        }
    }

}


Measured memory_bytes: 1792
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: u32 = read();

    let n = s / 100;
    let m = s % 100;

    let ans = if 0 < n && n <= 12 && 0 < m && m <= 12 {
        "AMBIGUOUS"
    } else if 0 < m && m <= 12 {
        "YYMM"
    } else if 0 < n && n <= 12 {
        "MMYY"
    } else {
        "NA"
    };

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
	int i;
	int n;
	int a[10000];
	int count = 0;

	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			count++;
			a[i] /= 2;
		}
	}

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


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void move(int,int);
int map[51][51];
int w,h;
int main()
{
  int i,j,count;
  
  while(1){
    scanf("%d%d",&w,&h);
    if(w==0&&h==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf("%d",&map[i][j]);
      }
    }
    count=0;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(map[i][j]==1){
          count++;
          move(i,j);
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

void move(int hh,int ww)
{
  if(ww<0||hh<0||hh>h||ww>w||map[hh][ww]==0)return;
  map[hh][ww]=0;
  move(hh+1,ww);
  move(hh+1,ww+1);
  move(hh+1,ww-1);
  move(hh,ww+1);
  move(hh,ww-1);
  move(hh-1,ww+1);
  move(hh-1,ww);
  move(hh-1,ww-1);
}
  

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

int main(){
  string s;
  int sum=1000;
  cin>>s;
  vector<int> t(s.size());
  for(int i=0;i<s.size();i++){
    switch(s.at(i)){
      case '1':t.at(i)=1;break;
      case '2':t.at(i)=2;break;
      case '3':t.at(i)=3;break;
      case '4':t.at(i)=4;break;
      case '5':t.at(i)=5;break;
      case '6':t.at(i)=6;break;
      case '7':t.at(i)=7;break;
      case '8':t.at(i)=8;break;
      case '9':t.at(i)=9;break;
      case '0':t.at(i)=0;break;
      default:break;
    }
  }
  for(int i=0;i<s.size()-2;i++){
    sum=min(sum,max(t.at(i)*100+t.at(i+1)*10+t.at(i+2)-753,753-t.at(i)*100-t.at(i+1)*10-t.at(i+2)));
  }
  cout<<sum<<endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, m, a[105], sm, c;
int main(){
	scanf("%d%d", &n, &m);
	rep(i,n){
		scanf("%d", a+i);
		sm += a[i];
	}
	rep(i,n) if(4*m*a[i] >= sm) c++;
	puts(c >= m ? "Yes" : "No");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int num = -1;
		int min = Math.min(a*100/8, b*10);
		int max = Math.max(a*100/7, b*100/9);
		for (int i = min; i < max; i++) {
			int ta = (int)(i*0.08);
			int tb = (int)(i*0.1);
			if(ta == a && tb == b) {
				num = i;
				break;
			}
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;


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

    int N, M;
    cin >> N >> M;

    int nr_days_assig = 0;
    while (M--)
    {
        int A;
        cin >> A;

        nr_days_assig += A;
    }

    cout << (N - nr_days_assig >= 0 ? N - nr_days_assig : -1);
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
   int n;cin>>n;
   vector<int> v(n);
   rep(i,0,n)cin>>v[i];

   sort(all(v));

   int sum=0;
   rep(i,0,n-1){
      sum+=v[i];
   }

   if(sum>v.back())cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
signed main(){
  int N,K;cin>>N>>K;
  N>=K*2-1?puts("YES"):puts("NO");
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int AA=S.size();
  int ZZ=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'){
      AA=min(i,AA);
    }
    if(S.at(i)=='Z'){
      ZZ=max(ZZ,i);
    }
  }
  cout << ZZ+1-AA << endl;
}
      

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MOD(x) ((x) % (1e9 + 7))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%d", &n);
	VI l(n);
	EACH(e, l) { scanf("%d", &e); }

	sort(ALL(l));
	int result = 0;
	for(auto i = l.begin() + 2; i < l.end(); i++) {
		for(auto j = l.begin(); j < i - 1; j++) {
			int lower = *i - *j + 1;
			int upper = *i + *j - 1;
			result += distance(lower_bound(j + 1, i, lower),
							   upper_bound(j + 1, i, upper));
		}
	}

	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int cnt = 0;
    rep(i, N) {
        if (S[i] == '.') ++cnt;
    }
    int ans = cnt;
    rep(i, N) {
        if (S[i] == '.') --cnt;
        else ++cnt;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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

typedef int INT_;

#define int long long

const int MAX = 1e5 + 10;

INT_ main()
{
	int a[MAX]={0};
	int i=2;

	while(i*i<MAX){
		if(a[i] != 1) {
			int j=i;
			j += i;
			while(j < MAX){
				a[j]=1;
				j += i;
			}
		}
		i++;
	}

	int p[MAX]={0};
	for(int i=3;i<MAX;i+=2){
		if(a[i]==0 and a[(i+1)/2]==0) p[i]=1;
	}

	for(int i=1;i<MAX;i++) p[i] += p[i-1];

	int q; cin>>q;
	
	while(q--){
		int l,r; cin>>l>>r;
		cout<<p[r]-p[l-1]<<endl;
	}	
}	

Measured memory_bytes: 2176
import math

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


def calculate(n, m):
    res = 1
    for i in range(1, int(math.pow(m, 0.5))):
        if m % i != 0:
            continue

        j = m // i

        if i <= m // n:
            res = max(res, i)

        if j <= m // n:
            res = max(res, j)

    print(res)


calculate(N, M)


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const double PI = 4.0*atan(1.0);

ll n;

int main(){
	cin>>n;
	for(ll i=1;i<=3500;i++) for(ll j=1;j<=3500;j++){
		ll A=i*j*n,B=4*i*j-(i+j)*n;
		if(B&&A%B==0&&A/B>1){
			cout<<i<<' '<<j<<' '<<A/B<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

template<typename T> struct BIT{
    vector<T> dat;
    ll sz;
    //all 1-indexed
    BIT(ll sz) : sz(sz){
        dat.assign(++sz, 0);
    }

    T sum(ll k){
        T ret = 0;
        for(++k; k > 0; k -= k & -k) ret += dat[k];
        return (ret);
    }

    void add(ll k, T x){
        for(++k; k < dat.size(); k += k & -k) dat[k] += x;
    }
    
    ll get(T k){
        if(k <= 0) return 0; 
        ll ret = 0;
        int n = 1; while(n < sz) n *= 2;
        for(int i=n/2; i>0; i/=2){
            if(ret+i < sz && dat[ret+i] < k){
                k -= dat[ret+i];
                ret += i;
            }
        }
        return ret;
    }
};

BIT<int> bit0(101010);
BIT<int> bit1(101010);

void range_sum(ll l, ll r, int x){
    bit0.add(l,-x*(l-1));
    bit0.add(r+1,x*r);
    bit1.add(l,x);
    bit1.add(r+1,-x);
}

int query(int i){
    if(i < 0) return 0;
    return bit0.sum(i) + bit1.sum(i) * i;
}

int main(){
    int n,m; cin >> n >> m;
    vector<vector<pii>> v(m);
    rep(i,n){
        int a,b; cin >> a >> b;
        v[b-a].emplace_back(a,b);
    }
    int now = 0;
    REP(i,1,m+1){
        for(pii j : v[i-1]){
            now++;
            range_sum(j.first, j.second, 1);
        }
        int ans = now;
        for(int j=i; j<=m; j+=i){
            ans -= query(j) - query(j-1);
        }
        cout << n - ans << "\n";
    }
}

Measured memory_bytes: 10896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int n=str.length();
    vector<int> ans(n+1,-1);
    bool startZero=false;
    int prev=0;
    if(str[0]=='<')
    {
        ans[0]=0;
        startZero=true;
    }
    for(int i=0;i<n-1;i++)
    {
        // between i-1 and i
        if(str[i]=='>'&&str[i+1]=='<')
        {
            ans[i+1]=0;
            startZero=true;
            prev=0;
            continue;
        }
        if(startZero&&str[i]=='<'&&str[i+1]=='<')
        {
            ++prev;
            ans[i+1]=prev;
        }
        else
        {
            startZero=false;
        }
    }
    startZero=false;
    prev=0;
    if(str[n-1]=='>')
    {
        ans[n]=0;
        startZero=true;
    }
    for(int i=n-2;i>=0;i--)
    {
        if(str[i+1]=='<'&&str[i]=='>')
        {
            ans[i+1]=0;
            startZero=true;
            prev=0;
            continue;
        }
        if(startZero&&str[i]=='>'&&str[i+1]=='>')
        {
            ++prev;
            ans[i+1]=prev;
        }
        else
        {
            startZero=false;
        }
    }
    for(int i=0;i<n-1;i++)
    {
        if(str[i]=='<'&&str[i+1]=='>')
        {
            ans[i+1]=1+max(ans[i],ans[i+2]);
        }
    }
    if(str[0]=='>')
    {
        ans[0]=1+ans[1];
    }
    if(str[n-1]=='<')
    {
        ans[n]=1+ans[n-1];
    }
    long long sum=0;
    for(auto const&e:ans)
    {
        sum+=e;
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 5780
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod =1'000'000'007;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }

    int MAX = 0;
    for (auto ele : mp){
        MAX = max(MAX, ele.second);
    }
    for (auto ele : mp){
        if (ele.second == MAX) cout << ele.first << endl;
    }
    return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	string a; cin >> a; 
	int ans = 0;
	for(int i =0; i < a.size()  / 2; i++) {
		if (a[i] != a[a.size() - i - 1]) ans++;
	}
	
	cout << ans << endl;
	return 0; 
}

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

using namespace std;

int main() {
  int A, B, M;

  cin >> A >> B >> M;

  vector<int> a(A);
  int minA = 1000000;
  for (int i = 0; i < A; i++){
    cin >> a[i];
    minA = min(minA, a[i]);
  }

  vector<int> b(B);
  int minB = 1000000;
  for (int i = 0; i < B; i++) {
    cin >> b[i];
    minB = min(minB, b[i]);
  }

  int ans = minA + minB;
  for (int i = 0; i < M; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;

    ans = min(ans, a[x] + b[y] - c);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#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()
{
    string n;
    cin >> n;
    int ans = 0;
    rep(i, n.size()) ans += n[i] - '0';
    if (ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3728
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int strNum = sc.nextInt();
        int strLen = sc.nextInt();
        List<String> strList = scanList(sc,strNum);


        System.out.println(execute(strNum,strLen,strList));

    }

    public static String execute(int strNum, int strLen, List<String> strList) {
        strList.sort(Comparator.naturalOrder());
        StringBuffer buf = new StringBuffer();
        for(String str : strList){
            buf.append(str);
        }

        return buf.toString();
    }

    public static List<String> scanList(Scanner sc,int num){
        List<String> scanList = new ArrayList<>();
        for(int i = 0; i <= num ; i++){
            scanList.add(sc.nextLine());
        }
        return scanList;
    }
}


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

using LL = long long;

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

    LL N, T;

    cin >> N >> T;

    vector<LL> t(N);

    for(int i = 0; i < N; i++){
        cin >> t[i];
    }

    LL count = 0;

    for (int i = 0; i < N-1; i++){
        if(t[i + 1] - t[i] > T){
            count += T;
        }else{
            count += t[i + 1] - t[i];
        }
    }
    count += T;

    cout << count << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int A, B, sum_digit, retval=1000;

  for (int i=1;i<N;i++){
    A = i;
    B = N - A;
    sum_digit = 0;
    while (A>0 || B>0){
      sum_digit += A%10 + B%10;
      A/=10;
      B/=10;
    }
    retval = min(retval, sum_digit);
  }
  cout << retval << endl;
}

  
  

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
a, i = 0, 1
while i < N - 1:
    a += A[i]
    i += 2
ans = [sum(A) - a * 2]
i = 1
while i < N:
    ans.append(A[i - 1] * 2 - ans[len(ans) - 1])
    i += 1
for i in ans:
    print(str(i) + ' ', end='')

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  string str;cin>>str;
  bool flag=0,flag2=0;
  for(int i=0;i<str.size()-1;i++){
    if(str[i]=='A'&&str[i+1]=='C')flag=true;
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> arr(n);
  for(int i=0;i<n;i++)
    cin>>arr[i];
  vector<int> cost(n,0);
  for(int i=1;i<n;i++)
  {
    int temp=INT_MAX;
    for(int j=1;j<=k&&i-j>=0;j++)
      temp=min(abs(arr[i-j]-arr[i])+cost[i-j],temp);
    cost[i]=temp;
  }
  cout<<cost[n-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
#define N 100

int main()
{
	int n;
	cin >> n;
	int p[N + 1], m[N + 1][N + 1];
	for (int i = 0; i < n; i++) {
		cin >> p[i] >> p[i + 1];
	}
	for (int i = 1; i <= n; i++) {
		m[i][i] = 0;
	}
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k < j; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	cout << m[1][n] << endl;
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}
 
 
int nextInt() { int x; scanf("%d", &x); return x;}
 
const int MAX_N = 100000;
vector<int> g[MAX_N];
 
int f(int v, int prev) {
  int x = 0;
  for (int u : g[v]) if (u != prev) {
    x ^= f(u, v);
  }
  x += 1;
  // cout << v << " " << x << endl;
  return x;
}
 
int main2() {
  int N = nextInt();
  REP(i, N) g[i].clear();
  REP(_, N-1) {
    int x = nextInt() - 1;
    int y = nextInt() - 1;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int nim = f(0, -1) - 1;
  if (nim == 0) cout << "Bob" << endl; 
  else cout << "Alice" << endl;
  return 0;
}
 
int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 10368
def search(a,b,dx,dy,t,check,li,answer):
    for i in range(len(dx)):
            temp = [t[0]+dx[i],t[1]+dy[i]]
            if mapCheck(a,b,temp):
                if check[temp[1]][temp[0]] == 0:
                    if li[temp[1]][temp[0]] == '.':
                        answer += 1
                        check[temp[1]][temp[0]] = 1
                        answer = search(a,b,dx,dy,temp,check,li,answer)
    return answer
                    
                
            
def mapCheck(a,b,t):
    if t[0] <= a-1 and t[0] >=0:
        if t[1] <= b-1 and t[1] >= 0:
            return True
    return False

while True:
    li = []
    answer = 1
    start = [0,0]
    a,b = map(int, input().strip().split(' '))
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    if a == 0 and b == 0:
        break
    for i in range(b):
        li.append(input().strip().split())
    check = [[0 for i in range(a)] for j in range(b)]
    for i in range(len(li)):
        li[i] = str(li[i])
        li[i] = list(li[i])
        del li[i][0]
        del li[i][0]
        del li[i][len(li[i])-1]
        del li[i][len(li[i])-1]
        for j in range(len(li[i])):
            if li[i][j] == '@':
                start = [j,i]
    print(search(a,b,dx,dy,start,check,li,answer))
                
                
        


        
        



Measured memory_bytes: 6020
def pyon(point,count,n,box,M):
    count +=1
    adress=[]
    for xx,yy in ((1,1),(1,0),(1,-1),(0,1),(0,0),(0,-1),(-1,1),(-1,0),(-1,-1)):box[M[count-1][1]+yy][M[count-1][0]+xx]=count
    for py,px in point:
        for xx,yy in ((2,1),(2,0),(2,-1),(-1,2),(0,2),(1,2),(-2,1),(-2,0),(-2,-1),(1,-2),(0,-2),(-1,-2)):
            if box[py+yy][px+xx]==count and (py+yy,px+xx) not in adress:adress.append((py+yy,px+xx))
    if count==n and len(adress)!=0:return "OK"
    elif len(adress)==0:return "NA"
    else:return pyon(adress,count,n,box,M)
    
while 1:
    px,py=map(int,input().split())
    if px==0:break
    point=[(py+2,px+2)]
    box=[[0]*14 for i in range(14)]
    n=int(input())
    N=list(map(int,input().split()))
    count=1
    M=[]
    for i in range(0, len(N), 2):M.append((N[i]+2,N[i+1]+2))
    print(pyon(point,0,n,box,M))


Measured memory_bytes: 5620
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,i,key,*A,j,n;
  scanf("%d",&N);
  A=(int*)malloc(sizeof(int) * N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  for(i=0;i<N;i++){
    key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){  
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    for(n=0;n<N;n++){
      printf("%d",A[n]);
      if(n<N-1)
	printf(" ");
    }
    printf("\n");
  }
    free(A);
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok
//string HOGE(".!\"#&%&'()*+,-/:"); // bad
//string HOGE(";<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'"); // bad
//string HOGE("()*+,-/:;<=>?@[\\"); // bad
//string HOGE("]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\"); // bad
//string HOGE("()*+,-/:;<=>?@[\\]^_`{|}~"); // bad

string HOGE(".!\"#&%&'()*,-/:;<=>?@[\\]^_`{|}~"); // ?

int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || c == '.' || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;}

Measured memory_bytes: 1224
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import itertools
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#C
def C():
    N = I()
    F = LIR(N)
    P = LIR(N)
    ans = -1*float("INF")
    kaiten = list((itertools.product([0,1], repeat=10)))
    del kaiten[0]
    for patern in kaiten:
        i = list(patern)
        anskaiten = [0 for i in range(N)]
        for youbi, n in enumerate(i):
            if n == 1:
                for nn,f in enumerate(F):
                    if f[youbi] == 1:
                        anskaiten[nn] += 1
        ansb = 0
        #print(anskaiten, end="")
        for k, p in enumerate(P):
            ansb += p[anskaiten[k]]
        ans = max(ans, ansb)
    print(ans)
        
def D():

    N, C = LI()
    STC = LIR(N)
    ans = 0
    
    #テレビチャンネルのテーブルを作成
    channel = [[0]*(10**5+2) for i in range(C+1)]

    #IMOS法を使用
    
    #初めにチャンネルテーブルごとの録画する時間の初めに+1
    #終わりの時間+1に-1をする
    #これは他チャンネルに変える際終わる時間と始まる時間が
    #同じとき録画機が2個いることを加味して+1ずらしている
    for s,t,c in STC:
        channel[c][s] += 1
        channel[c][t + 1] -= 1
    
    #次にチャンネルテーブルすべてを更新し、録画番組が
    #流れていないチャンネルには0をあたえ、そうでないときは
    #0以外の数字を与える
    for cha in channel:
        for num, CH in enumerate(cha):
            if num == 10 ** 5 + 1:
                break
            cha[num + 1] += CH
    
    #最後に毎秒ごとにチャンネルテーブルを見て番組が流れている
    #時はその時間の録画機を1追加し、秒数ごとに分け最大値を出力
    for i in range(10 ** 5 + 1):
        bf = 0
        for cha in channel:
            if cha[i]: bf += 1
        ans = max(ans, bf)
    print(ans)

if __name__ == '__main__':
    D()
    




Measured memory_bytes: 52176
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 15 12:28:59 JST 2020
 **/

const string RCP = "rsp";
signed main() {
    Int n, K;
    cin >> n >> K;
    vector<Int> scores(3);
    REP(i, 3) cin >> scores[i];
    string t;
    cin >> t;
    Int ans = 0;
    REP(i, n) {
        if (i - K >= 0 && t[i - K] == t[i]) {
            t[i] = '#';
            continue;
        }
        ans += scores[(RCP.find(t[i]) + 2) % 3];
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	char a[201];
	int b[100000];
	int c, d;
	int k;
	int n, m;
	int x;
	int min, fin;
	scanf("%d", &n);
	scanf("%s",a);
	m = 0;
	min = 0;
	for (int i = 0; i < n; i++){
		if (a[i] == '(')m++;
		else m--;
		if (m < min)min =m;
		if (i == n - 1)fin = m;
	}
	min = -min;
	for (int i = 0; i < min; i++)printf("(");
	fin = fin + min;
	for (int i = 0; i < n; i++)printf("%c", a[i]);
	for (int i = 0; i < fin; i++)printf(")");
	return 0;
}

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

int n,m;
int roads[51];

int main() {

    cin >> n >> m;

    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        roads[a]++;
        roads[b]++;
    }

    for(int i=1; i<=n; i++){
        cout << roads[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = sorted([sorted(input()) for i in range(n)])
a = []
last = s[0]
count = 1
for i in range(1, n):
    if s[i] == last:
        count += 1
    else:
        a.append(count)
        count = 1
    last = s[i]
a.append(count)
ans = 0
for i in a:
    if i > 1:
        ans += i * (i - 1) // 2
print(ans)

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

def g(n, x):
    cnt = 0
    while True:
        n = n // x
        cnt += n // 2
        if n == 0:
            break
    return cnt

if n % 2 != 0:
    print(0)
else:
    print(min(g(n, 2), g(n, 5)))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(a>b||(a!=b&&n==1)){
        cout<<0<<endl;
    }
    else{
        if(n==1||n==2){
            cout<<1<<endl;
        }
        else{
            ll max1=0,min1=0;
            ll ans=0;
            max1=ll(n-2)*b;
            min1=ll(n-2)*a;
            ans=ll(max1-min1+1);
            cout<<ans<<endl;
        }
    }
}

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

constexpr int INF = 1 << 30;

void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    vector<int> cnt(K+1);
    int ans = INF, s=0;
    for(int l=0,r=0;l<N;l++){
        while(r<N && s<K){
            if(A[r]<=K){
                if(cnt[A[r]]==0) s++;
                cnt[A[r]]++;
            }
            r++;
        }
        if(s==K){
            ans = min(ans, r-l);
        }
        if(A[l]<=K){
            cnt[A[l]]--;
            if(cnt[A[l]]==0) s--;
        }
    }    
    cout << (ans<INF ? ans : 0) << endl;
}

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



Measured memory_bytes: 3588
#include"bits/stdc++.h"
using namespace std;

int main() {

	int N;
	cin >> N;

	long long L[100];
	L[0] = 2;
	L[1] = 1;

	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}

	cout << L[N] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define ff first
#define ss second
using namespace std;
typedef pair<int,int> pii;

const int M = 1e9 + 7;

inline int mod(int a,int b){
  int r = a%b;
  if(r<0)r+=b;
  return r;
}

int exp(int a,int b,int m){
  if(b==0)return 1;
  if(b==1)return a;
  int k = exp(a,b/2,m);
  if(b&1){
    return mod(a*mod(k*k,M),M);
  }
  return mod(k*k,M);
}

int32_t main(){
  int ans=0;
  int n,k;
  cin>>n>>k;
  int inv2 = exp(2,M-2,M);
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  
  for(int i=0;i<n;i++){
    int antes=0;
    int dps=0;
    for(int j=0;j<i;j++){
      if(v[i]>v[j])antes++;
    }
    for(int j=i+1;j<n;j++){
      if(v[i]>v[j])dps++;
    }
    
    int tot = antes+dps;
    int x = mod(inv2*mod(k*(k+1),M),M);
    dps = mod(x*dps,M);
    int y = mod(inv2*mod(k*(k-1),M),M);
    antes = mod(antes*y,M);
    ans = mod(ans + antes+dps,M);
     
  }
    cout<<ans<<endl;
  
}

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

int main(){
	
	int a,b;

	while (cin >> a >> b) {
		if(a<b) printf("a < b\n");
		else if(a>b) printf("a > b\n");
		else printf("a == b\n");
	}
	return 0;
}


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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int h, w;
int c[10][10];
int a[205][205], cnt[10];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, 10)rep(j, 10) cin >> c[i][j];
    rep(i, h)rep(j, w) cin >> a[i][j];
    rep(k, 10)rep(i, 10)rep(j, 10) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }
    rep(i, h)rep(j, w) {
        if (a[i][j] == -1) continue;
        cnt[a[i][j]]++;
    }
    int ans = 0;
    rep(i, 10) {
        if (i == 1) continue;
        ans += c[i][1] * cnt[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
//
//  main.c
//  q_03
//
//  Created by k19104kk on 2020/08/22.
//  Copyright © 2020 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    long long n;
    scanf("%lld", &n);
    
    long long a[n];
    
    for (int i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }
    
    long long sum=0;
    
    for (int i=0; i<n; i++) {
        if (i>=1) {
            if (a[i-1]>a[i]) {
                sum+=a[i-1]-a[i];
                a[i]=a[i-1];
            }
        }
    }
    
    printf("%lld\n", sum);
    
    
    
    return 0;
}


Measured memory_bytes: 3248
#include <iostream>
#include <stdio.h>

using namespace std;

struct Dice{

	int u;	int w;	int s;	int e;	int n;	int d;
	
	Dice (int d1, int d2, int d3, int d4, int d5, int d6)
		{u = d1; s = d2; e = d3; w = d4; n = d5; d = d6;}
	
	Dice (int *num){
		u = num[0]; s = num[1]; e = num[2];
		w = num[3]; n = num[4]; d = num[5];}
	
	Dice ()
		{u = 1; s = 2; e = 3; w = 4; n = 5; d = 6;}

	void rotate(char *direction){
		int dam = 0;
		for (int i = 0; direction[i] != '\0'; i++){
			switch (direction[i]){
			case 'E':
				dam = e;
				e = u; u = w; w = d; d = dam;
				break;
			case 'N':
				dam = n;
				n = u; u = s; s = d; d = dam;
				break;
			case 'S':
				dam = s;
				s = u; u = n; n = d; d = dam;
				break;
			case 'W':
				dam = w;
				w = u; u = e; e = d; d = dam;
				break;
			case 'X'://???????????¢
				dam = w;
				w = s; s = e; e = n; n = dam;
				break;
			default:
				break;
			}
		}
	}	
	
	void display(char direction){
		switch (direction){
			case 'E': printf("%d\n",e); break;
			case 'N': printf("%d\n",n); break;
			case 'S': printf("%d\n",s); break;
			case 'W': printf("%d\n",w); break;
			case 'U': printf("%d\n",u); break;
			case 'D': printf("%d\n",d); break;
			default: break;
		}
	}
};


int main(){
	int num[6];
	for (int i = 0; i < 6; i++)cin >> num[i];
	Dice d = num;
	Dice dd = num;//?????????????¨???¶
	
	int q, a, b;
	cin >> q;
	for (int i = 0; i < q; i++){
		cin >> a >> b;
		//a????????????
		if (d.n == a) d.rotate("S");
		else if(d.e == a) d.rotate("W");
		else if(d.s == a) d.rotate("N");
		else if(d.w == a) d.rotate("E");
		else if(d.d == a) d.rotate("EE");
		for (int i = 0; i < 4; i++){
			if (d.s == b) d.display('E');
			d.rotate("X");
		}
		//d = dd;
	}
	
	return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>
int main(void);
int main(void){
  int n,i,m,s;
  scanf("%d",&n);
  int l[n];
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  m=l[0];
  s=l[0];
  for(i=1;i<n;i++){
    s = s+l[i];
    if(l[i]>m){
      m=l[i];
    }
  }
  if(2*m<s){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}

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

   typedef long long ll;
   typedef pair<ll, ll> P;

   const double EPS = (1e-7);
   const ll INF =(1e15);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

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

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

const ll MAX_N = 1e5;
const ll MAX_Q = 1e5;

ll n, q;
ll com[MAX_Q], x[MAX_Q], y[MAX_Q];
ll dat[4 * MAX_N - 1];

//初期化
void init(ll n_){
    //要素数を2のべき乗にする
    n = 1;
    while (n < n_) n *= 2;

    //すべての値を2^31 - 1に
    REP(i, 2 * n - 1){
        dat[i] = ((1ull << 31) - 1);
    }
}

//A[i] を xに変更する
void update(ll i, ll x){
    i += n - 1;
    dat[i] = x;

    while (i > 0){
        i = (i - 1) / 2;
        dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
}


//[a,b)の最小値を出力する
//k = 節点の番号 [l, r)は対応する区間
//したがって[a, b)の最小値はquery(a, b, 0, 0, n)として呼ぶ
ll query(ll a, ll b, ll k, ll l, ll r){
    //[a, b)と[l, r)が交差しなければINF;
    if (r <= a || b <= l) return INF;

    //[a, b)が[l, r)を完全に含んでいれば、節点kが持つ値
    if (a <= l && r <= b) return dat[k];
    else{
        //その他の場合は, 2つの子の最小値
        ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }    
}

int main(){

    //input
    cin >> n >> q;
    REP(i, q){
        cin >> com[i] >> x[i] >> y[i];
    }
    init(n);
    REP(i, q){
        if (com[i] == 0) update(x[i], y[i]);
        else cout << query(x[i], y[i]+1, 0, 0, n) << endl;
    }
    return 0;
}


Measured memory_bytes: 7524
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin >> k;

    cout << a[k - 1] << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int number;
    cin >> number;
    for(int i=0; i<3; i++) {
        if(number % 10 == 7) cout << "Yes\n", exit (0);
        number /= 10;
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3592