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



int main(){
  int s[150000]={};
  s[0]=2;
  int count=1;
  for(int i=3;i<150000;i+=2){
    bool j=true;
    for(int t=0;s[t]*s[t]<=i;t++){
      if(s[t]==0){break;}
      if(i%s[t]==0){j=false; break;}
    }
    if(j){s[count]=i; count++;}
  }


  while(1){

  int n,p;
  cin>>n>>p;
  if(n==-1 && p==-1){break;}
  for(int i=0;i<150000;i++){
    if(s[i]>n){count=i; break;}
  }
  vector<int> a(0);
  for(int i=count;i<=count+p;i++){
    for(int t=i;t<=count+p;t++){
      a.push_back(s[i]+s[t]);
    }
  }
  sort(a.begin(),a.end());
  
  cout<<a[p-1]<<endl;

  }
  

  
  
  return 0;
}



Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    
    double ans = 0;

    rep(i,n){
        double a; string b;
        cin >> a >> b;
        if(b == "JPY") ans+=a;
        else ans += a*380000.00000;
    }

    cout << fixed << setprecision(10) << ans << endl;
}
    

Measured memory_bytes: 256
//
// Created by tac on 2016/10/12.
//

#include <cstdlib>
#include <iostream>

int main() {
    int n;

    std::cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0) {
            std::cout << " " << i;
        } else {
            for (int j = i; j > 0; j /= 10) {
                if (j % 10 == 3) {
                    std::cout << " " << i;
                    break;
                }
            }
        }
    }
    std::cout << std::endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N, T, A, ans = 1;
  cin >> N >> T >> A;
  vector<int> H(N);
  vector<float> t(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
    t.at(i) = T - H.at(i) * 0.006;
  }
  float dif = abs(t.at(0) - A);
  for(int i = 1; i < N; i++){
    if(dif > abs(t.at(i) - A)){
      dif = abs(t.at(i) - A);
      ans = i + 1;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3592
h,w = map(int,input().split())
 
C = []
for i in range(10):
    C.append(list(map(int,input().split())))
 
def warshall_floyd(d):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

trans_map = warshall_floyd(C)
ans = 0
for _ in range(h):
    A = list(map(int,input().split()))
    for a in A:
        if a==-1:
            continue
        else:
            ans += trans_map[a][1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=2e5+5;
struct Node{
    int a,b;
}e[maxm];
int n;
bool cmp(Node a,Node b){
    if(a.b!=b.b)return a.b>b.b;
    return a.a>b.a;
}
signed main(){
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>e[i].a>>e[i].b;
    }
    sort(e+1,e+1+n,cmp);
    int cur=e[1].b;
    for(int i=1;i<=n;i++){
        int a=e[i].a,b=e[i].b;
//        cout<<cur<<' '<<a<<' '<<b<<endl;
        if(cur>b)cur=b;
        if(cur-a<0){
            cout<<"No"<<endl;
            return 0;
        }
        cur-=a;
    }
    cout<<"Yes"<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 6732
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];
int I[100][20];
char s[100][100];

int main() {
	ll n;
	cin >> n;
	vector<ll>name(5, 0);
	rep(i, n) {
		string s;
		cin >> s;
		if (s[0] == 'M')name[0]++;
		else if (s[0] == 'A')name[1]++;
		else if (s[0] == 'R')name[2]++;
		else if (s[0] == 'C')name[3]++;
		else if (s[0] == 'H')name[4]++;
	}
	ll ans = 0;
	for (int i = 0;i < 5;++i) {
		for (int j = i + 1;j < 5;++j) {
			for (int k = j + 1;k < 5;++k) {
				ans += name[i] * name[j] * name[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int MOD = 1e9+7;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int bkt[61],bkt2[61];
    rep(i,61) {bkt[i]=0; bkt2[i]=0;}
    int sum=0;
    int a[N];
    rep(i,N){
        cin >> a[i];
    }
    rep(i,61){
        rep(j,N){
            if((a[j]>>i)&1){
                bkt[i]++;
            } else {
                bkt2[i]++;
            }
        }
        sum+=(((bkt[i]*bkt2[i])%MOD)*((1ll<<i)%MOD))%MOD;
        sum %= MOD;

    }
    cout << sum << endl;
}


Measured memory_bytes: 2560
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int n;cin>>n;
    int arr[n];fr(i,0,n-1)cin>>arr[i];
    int dp[n];fr(i,0,n-1)dp[i]=1e9;
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    fr(i,2,n-1){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}


Measured memory_bytes: 4412
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    n,k = IL()
    s = [0]*n
    d = deque()
    for __ in range(k):
        d = I()
        tmp = deque(LI())
        for _ in range(d):
            s[tmp.pop()-1] += 1
    print(s.count(0))
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9472
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main()
{
    int a,b,c,n,ans;
    a = 0;
    bool hantei;
    cin >> n;
    
    for(int i = 0; i <= 30; i++)
    {
        
        for(int j = 0; j <= 20; j++)
        {
            
            if (i*7 + j*4 == n) {
                a++;
            }
            
        }
        
    }
    if(a != 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int, int>
#define pll pair <ll, ll>
#define gcd __gcd
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e2+5;

ll adj[L][L];

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL); cout.tie(NULL);
    
    ll N, K;
    cin >> N >> K;

    ll m = ((N-1)*(N-2))/2;

    if(K>m)
    {
        cout << -1 << endl;
    }

    else
    {
        for(ll i=2; i<=N; i++)
        {
            adj[1][i] = 1;
        }

        ll edges = N-1;
        // K-=m;

        // cout << K << endl;

        ll first = 2;
        ll second = 3;

        while(m>K)
        {
            adj[first][second] = 1;
            edges++;

            second++;

            if(second == N+1)
            {
                first++;
                second = first+1;
            }

            m--;
        }

        cout << edges << endl;

        for(ll i=1; i<=N; i++)
        {
            for(ll j=1; j<=N; j++)
            {
                if(adj[i][j])
                {
                    cout << i << " " << j << endl;
                }
            }
        }
    }



    return 0;
}

Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N, x;
    cin >> N >> x;

    if (x == 1 || 2 * N - 1 == x) {
        cout << "No" << endl;
        return 0;
    }

    int len = 2 * N - 1;
    vector<int> ans(len, -1);
    ans[len / 2] = x;
    ans[len / 2 - 1] = x - 1;
    ans[len / 2 + 1] = x + 1;

    set<int> S;
    S.insert(x);
    S.insert(x - 1);
    S.insert(x + 1);

    int d = 1;
    for (int i = 0; i < len; i++) {
        if (ans[i] == -1) {
            while (S.find(d) != S.end()) d++;
            ans[i] = d;
            S.insert(d);
        }
    }

    cout << "Yes" << endl;
    for(int i = 0;i<len;i++) cout << ans[i] << endl;

    return 0;
}

















































Measured memory_bytes: 11648
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for1l(n) for (ll i = 0 ; i < n ; i++)
#define for2l(n) for (ll j = 0 ; j < n ; j++)

int main() {
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    if (r < 1200) cout << "ABC";
    else if (r < 2800) cout << "ARC";
  	else cout << "AGC";
}

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

int main(){
    int i,j,n,doudemoii,count,huga;
    cin >> n;
    int ans[n+1000][n+1000];
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
        ans[i][j] = 0;
        }
    }

    for(i=0; i < n; i++){
        cin >> doudemoii >> count;
        for(j = 0; j < count; j++){
            cin >> huga;
            ans[i][huga-1] = 1;
        }
    }
    for(i = 0; i< n; i++){
        for(j = 0; j < n; j++){
            if(j < n-1)cout << ans[i][j] << ' ';
            else cout << ans[i][j] << endl;
        }
    }
}


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

int main()
{
  int n, x;
  cin >> n >> x;
  
  vector<int> a(n);
  for (int i = 0; i < n; i ++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int happy = 0;
  for (int i = 0; i < n; i ++)
  {
    if (x < a.at(i)) break;
    else if (i == n - 1 && a.at(i) != x) break;
    x -= a.at(i);
    happy ++;
  }
  
  cout << happy;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fi first
#define se second
#define pb push_back
#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);

using namespace std;

template<typename T> void macro_scan(T& t){cin>>t;};
template<typename F, typename ...R>void macro_scan(F& f , R& ...r){
  cin>>f;macro_scan(r...);
}

void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<" ";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    read(int , a , b , c);
    cout<<max(c - (a - b) , 0 )<<"\n";
}




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

template <typename _tp> inline void read(_tp&x){
	char c11=getchar(),ob=0;x=0;
	while(c11!='-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;
}

const int N = 101000 ,p = 1e9+7;
char s[N];int n;
int t[200];

int main(){
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;++i) ++t[s[i]-'a'];
	int res = 1;
	for(int i=0;i<26;++i) res = (ll)res * (t[i]+1)%p;
	printf("%d\n",(res-1+p)%p);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
#define NIL -1
#define MAX 25
struct Node 
{
    int parent, left, right;
};

Node node[MAX];
int depth[MAX];
int height[MAX];


void setDepth(int u, int d)
{
    if ( u == NIL){
        return ;
    }
    depth[u] = d;
    setDepth(node[u].left, d + 1);
    setDepth(node[u].right, d + 1);
    
}

int setHeight(int u)
{
    int h1 = 0, h2 = 0;
    if (node[u].left != NIL){
        h1 = setHeight(node[u].left) + 1;
    }
    if (node[u].right != NIL){
        h2 = setHeight(node[u].right) + 1;
    }
    return height[u] = max(h1, h2);
    
    
}

void print(int u)
{
    cout << "node " << u << ": ";
    cout << "parent = " << node[u].parent << ", ";
    cout << "sibling = ";
    if (node[u].parent == NIL){
        cout << "-1, ";
    } else if (node[node[u].parent].left == u){
        cout << node[node[u].parent].right << ", ";
    } else {
        cout << node[node[u].parent].left << ", ";
        
    }
    
    
    cout << "degree = ";
    if (node[u].left != NIL && node[u].right != NIL){
        cout << "2";
    } else if(node[u].left != NIL || node[u].right != NIL){
        cout << "1";
    } else {
        cout << "0";
    }
    cout << ", ";
    cout << "depth = " << depth[u] << ", ";
    cout << "height = " << height[u] << ", ";
    if (node[u].parent == NIL){
        cout << "root";
    } else if (node[u].left == NIL && node[u].right == NIL){
        cout << "leaf";
    } else {
        cout << "internal node";
    }
    cout << endl;
}

int main()
{
    int n;
    int id;
    int root = 0;
    
    cin >> n;
    for (int i = 0; i < n; i++){
        node[i].parent = node[i].left = node[i].right = NIL;
    }
    for (int i = 0; i < n; i++){
        cin >> id;
        int l, r;
        cin >> l >> r;
        node[id].left = l;
        node[id].right = r;
        if (l != NIL){
            node[l].parent = id;
        }
        if (r != NIL){
            node[r].parent = id;
        }
        
        
    }
    for (int i = 0; i < n; i++){
        if (node[i].parent == NIL){
            root = i;
        }
    }

    setDepth(root, 0);
    setHeight(root);
    
    for (int i = 0; i < n; i++){
        print(i);
    }
    return 0;
    
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
using namespace std;

int minChange(string s1,string s2)
{
 int c=0;
 for(int i=0;i<s1.length();i++)
 if(s1[i]!=s2[i])
 c++;
 
 return c;
}

int main()
{
  string s,t,temp;
  cin>>s>>t;
  int l1=s.length();
  int l2=t.length();
  int ans=l2;
  for(int i=0;i<l1-l2+1;i++)
  {
    temp=s.substr(i,l2);
    ans=min(ans,minChange(temp,t));
  }
  cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
using namespace std;


int main(){
    int a, b, cnt = 0;
    cin >> a >> b;
    for (int i = a ; i <= b; i++) {
        int dig[5];
        int tmp = i;
        for (int j = 0; j < 5; j++) {
            dig[j] = tmp % 10;
            tmp /= 10;
        }
        if(dig[0] == dig[4] && dig[1]==dig[3])cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	int a,b;
	cin >> a >> b;
	if(a <= 0 && b >= 0) {
		cout << "Zero" << endl;
	}
	else if(a <= 0 && b <= 0) {
		if(( b - a + 1 )% 2 == 0) {
			cout << "Positive" << endl;
		}
		else {
			cout << "Negative" << endl;
		}
	}
	else {
		cout << "Positive" << endl;
	}
}

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

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
#define  mod  1000000007
#define  endl  "\n"
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

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

int op(int a,int b)
{
    return max(a,b);
}

#define mm 300055
int a[mm],t[6*mm];

void update(int node,int i,int s,int e)
{
    if(s==e)
        t[node]=a[i];
    else
    {
        int mid=(s+e)/2;
        if(s<= i && i<=mid)
            update(2*node,i,s,mid);
        else
            update(2*node+1,i,mid+1,e);
        
        t[node]=op(t[2*node],t[2*node+1]);
    }
    
}

int query(int node,int l,int r,int s ,int e)
{
    
    if(l>e || r<s)
        return 0;
    if(l<=s && e<=r)
        return t[node];
    int mid=(s+e)/2;
    int p1=query(2*node,l,r,s,mid);
    int p2=query(2*node+1,l,r,mid+1,e);
    return op(p1,p2);
}

int32_t main()
{
    fast
    int n,x,k,ans=1;
    cin>>n>>k;
    f(i,1,n){
        cin>>x;
        int l=max(0LL,x-k);
        int r=min(300000LL,x+k);
        int y=query(1,l,r,0,300000);
        a[x]=max(a[x],y+1);
        ans=max(ans,a[x]);
        update(1,x,0,300000);
     
    }
    cout<<ans;
}

Measured memory_bytes: 14184
#include<stdio.h>
int n,r,p,c,i,deck[100],temp[100];

int main(){
  while(1){
    scanf("%d %d",&n,&r);
    if( n==0 && r==0)break;
    for( i = 1; i <=n; i++){
      deck[i] = n - i + 1;
    }
    while(r>0){
      r--;
      scanf("%d %d",&p,&c);
      for( i = 1; i < p; i++){
	temp[i]=deck[i];
      }
      for(i = p ; i < p + c; i++){
	deck[i-p+1] = deck[i];
      }
      for( i = 1; i < p; i++){
	deck[i+c] = temp[i];
      }
    }
    printf("%d\n",deck[1]);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(ll a,ll b){return b?GCD(b,a%b):a;}
int LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	int r[n], l[n];
	l[0] = a[0];
	r[n-1] = a[n-1];
	for (int i = 1; i < n; i++){
		l[i] = GCD(l[i-1], a[i]);
	}

	for (int i = n-2; i >= 0; i--){
		r[i] = GCD(r[i+1], a[i]);
	}

	int ans = r[1];

	for (int i = 1; i < n-1; i++){
		ans = max(ans, GCD(l[i-1], r[i+1]));
	}

	ans = max(ans, l[n-2]);

	cout << ans << endl;

}


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


int main(){
    int n; cin >> n;
    ll a,b;
    vector<pair<ll,ll>> p(n);
    rep(i,n){
        cin >> a >> b;
        p[i] = {b, a};
    }
    sort(p.begin(),p.end());
    ll time = 0;
    rep(i,n){
        time += p[i].second;
        if(time > p[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";

int main()
{
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for (int r = 0; r < 5000; r++)
  {
    for (int g = 0; g < 5000; g++)
    {
      int b = (N - (R * r + G * g)) / B;
      if (b >= 0 && R * r + B * b + G * g == N) ans++;
    }
    
  }
  

  cout << ans << endl;
}

Measured memory_bytes: 256
// ALDS1_2_C: Stable Sort

#[derive(Clone, Copy)]
struct Card {
    suit: char,
    value: char,
}

fn bubble_sort(
    a: &mut Vec<Card>,
    n: usize,
) {
    for i in 0..n {
        let mut j = n - 1;
        while j >= i + 1 {
            if a[j].value < a[j - 1].value {
                let t = a[j];
                a[j] = a[j - 1];
                a[j - 1] = t;
            }
            j -= 1;
        }
    }
}

fn selection_sort(
    a: &mut Vec<Card>,
    n: usize
) {
    for i in 0..n {
        let mut minj = i;
        let mut j = i;
        while j < n {
            if a[j].value < a[minj].value {
                minj = j;
            }
            j += 1;
        }
        let t = a[i];
        a[i] = a[minj];
        a[minj] = t;
    }
}

fn print(
    a: &Vec<Card>,
    n: usize,
) {
    print!("{}{}", a[0].suit, a[0].value);
    for i in 1..n {
        print!(" {}{}", a[i].suit, a[i].value);
    }
    println!();
}

fn is_stable(
    c1: &Vec<Card>,
    c2: &Vec<Card>,
    n: usize,
) -> bool {
    let mut flag = true;
    for i in 0..n {
        if c1[i].suit != c2[i].suit {
            flag = false;
            break;
        }
    }
    flag
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n = s.trim().parse::<usize>().unwrap();

    s.clear();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let mut c1: Vec<Card> = Vec::new();
    while let Some(s) = it.next() {
        let cs: Vec<char> = s.chars().collect();
        let card = Card {
            suit: cs[0],
            value: cs[1],
        };
        c1.push(card);
    }
    
    let mut c2: Vec<Card> = Vec::new();
    for c in &c1 {
        c2.push(c.clone());
    }

    bubble_sort(&mut c1, n);
    selection_sort(&mut c2, n);

    print(&c1, n);
    println!("Stable");
    print(&c2, n);
    if is_stable(&c1, &c2, n) {
        println!("Stable");
    } else {
        println!("Not stable");
    }
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
int x = 1 , y = 1;

int main(){
	cin >> N;
	repp(i,0,N){
		int A;
		cin >> A;
		x *= 3;
		if(A%2==0) y *= 2;
	}
	cout << x - y << endl;
	return 0;
}


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

int main() {
  int N;
  int C = 0;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }

  
  sort(V.begin(), V.end());

  for (int i = 2; i < N; i++) {
    for (int j = 1; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (V.at(i) != V.at(j) && V.at(i) != V.at(k) && V.at(j) != V.at(k) && V.at(i) + V.at(j) > V.at(k) && V.at(j) + V.at(k) > V.at(i) && V.at(k) + V.at(i) > V.at(j)) {
          C++;
        }
      }
    }
  }
  cout << C << endl;  
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    string s;
    cin>>s;
    ll n=s.size();
    ll dp[2][2019];
    ll ans=0;
    m0(dp);
    for (ll si = 0; si < n; si++) //s[i];
    {
        ll nowi = s[si]-'0';
        dp[1][nowi]++;
        for (ll i = 0; i < 2019; i++)
        {
            ll tmp=(i*10+nowi)%2019;
            dp[1][tmp]+=dp[0][i];
        }
        ans+=dp[1][0];
        for (ll i = 0; i < 2019; i++)
        {
            dp[0][i]=dp[1][i];
            dp[1][i]=0;
        }
        
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt64();
            var A = line[0];
            var B = line[1];

            var bits = new BitArray(64);

            bits[0] = ((B + 1) / 2 - A / 2) % 2 == 1;

            int i = 1;
            long x = 2;
            while (x <= B)
            {
                var aOdd = A % 2 == 1 && (A & x) != 0;
                var bOdd = B % 2 == 0 && (B & x) != 0;
                bits[i] = aOdd ^ bOdd;

                i++; x <<= 1;
            }

            var arr = new byte[8];
            bits.CopyTo(arr, 0);
            return BitConverter.ToInt64(arr, 0);
        }

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <cmath>
#include <map>

using namespace std;
struct bcpair{
  long long b,c;
};
bool karsilastir(bcpair s1, bcpair s2)
{
  return(s1.c > s2.c);
}

int main(){
  ios_base::sync_with_stdio(0);cin.tie(0);
  long long n, m, ans = 0, i, j, aindex = 0, pindex = 0;
  cin >> n >> m;
  vector<long long> a(1000010);
  //long int b[m];
  //long int c[m];
  vector<struct bcpair> pair(1000010);
  for(i = 0;i < n;i++){
    cin >> a[i];
  }
  for(i = 0;i < m;i++){
    cin >> pair[i].b >> pair[i].c;
  }
  sort(a.begin(), a.end(),greater<int>());
  sort(pair.begin(),pair.end(),karsilastir);
  i = 0;
  while(i < n){
    if(a[aindex] > pair[pindex].c){
      ans += a[aindex++];
      i++;
    }
    else{
      if(i + pair[pindex].b > n){
        ans += pair[pindex].c * (n - i);
        cout << ans << endl;
        return 0;
      }
      else{
        ans += pair[pindex].c * pair[pindex].b;
        i += pair[pindex++].b;
      }
    }
  }
  //for(i=0;i < m; i++){
    //for(j = 0;j < pair[i].b;j++){
      //if(pair[i].c > a[j]){
        //cout << "----" << endl;
        //a[j] = pair[i].c;
      //}
      //else{
      //  break;
      //}
    //}
    //sort(a.begin(), a.end());
  //}
  //for(i = 0;i < n;i++){
    //cout << a[i] << endl;
    //ans += a[i];
  //}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23680
#include <iostream>
#include<vector>

int main()
{
    std::vector<int> vec(6);
    for(int i=0 ; i<6 ; i++){
        std::cin >> vec[i] ;
    }
    int a;
    a=vec[0]*1+vec[1]*5+vec[2]*10+vec[3]*50+vec[4]*100+vec[5]*500;
    if(a<1000)std::cout<<0<<std::endl;
    else std::cout <<1 <<std::endl;
    return 0;
    }

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int n, x, t, ans;

int main() {
    //freopen("test.in", "r", stdin);
    scanf("%d %d %d\n", &n, &x, &t);
    ans = 0;
    while (n > 0) {
        ans += t;
        n -= x;
    }
    printf("%d\n", ans);
    return 0;
}


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

int main()
{
ll n , k ;
cin >> n >> k ;
vector<ll> v(n);
rep(i, n){
  cin >> v[i];
}
  //lower側がtrue judgeがtrueとなる最もupper側のvalを返す
  //lowerboundでもfalseなら-1を返す

auto judge = [&](ll val) {
  ll cnt=0;
  rep(i,n){
    cnt+=(v[i]-1)/val;
  }
  if(cnt>k)return true;
  else return false;
};
auto binarysearch = [&](ll lowerbound, ll upperbound) {
  if (!judge(lowerbound)) return -1LL;
  ll lower = lowerbound, upper = upperbound;
  while (1){
    if (judge((lower + upper) / 2)) lower = (lower + upper) / 2;
    else upper = (lower + upper) / 2;
    if (abs(upper - lower) <= 1){
      if (judge(upper)) return upper;
      else return lower;
    }
  }
};
cout << max(binarysearch(1, 1LL<<50)+1,1LL) << endl;
return 0;
}

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

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

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 2e3 + 10;
const ll MOD  = 924844033;
const ll INF  = 1e18;

ll n, k, F[2 * N][N], fact[N], ans;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> k;
    fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = i * fact[i - 1] % MOD;
    }
    int len = n / k, t = 2 * (n % k), timer = 1;
    F[0][0] = 1;
    for (int i = 0; i < 2 * k; i++) {
        int l = (i < t ? len + 1 : len);
        for (int j = 0; j < l; j++) {
            for (int k = 0; k <= n; k++) {
                F[timer][k] = F[timer - 1][k];
                if (j)
                    F[timer][k] = (F[timer][k] + F[timer - 2][k - 1]) % MOD;
            }
            timer++;
        }
    }
    for (int i = 0; i <= n; i++) {
        ans += F[timer - 1][i] * fact[n - i] % MOD * pw(MOD - 1, i, MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 66448
import java.math.BigInteger;
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int P = 0;
        int count=1;
        for(int i=1; i<=N; i++) {
            P+=sc.nextInt();
            if(P<=X) count++;
        }
        System.out.println(count);
   }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
LL num[200006];
map<LL,LL>my;
int main(void)
{
    int n;
    cin>>n;
    for(int i = 1;i <= n;i++)
        cin>>num[i];
    my[0] = 1;
    LL sum = 0;
    LL ask = 0;
    for(int i = 1;i <= n;i++)
    {
        sum += num[i];
        if(my.count(sum))
            ask += my[sum];
        my[sum]++;
    }
    cout<<ask<<endl;
    return 0;
}


Measured memory_bytes: 14336
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;
	private int N;

	public void mainrun() {
		scan = new Scanner(System.in);

		N = scan.nextInt();
		Card[] C1 = new Card[N],C2 = new Card[N];

		String[] str;

		for(int i = 0;i < N ; i++) {
			str = scan.next().split("");
			C1[i] = new Card(str[0],str[1],i);
			C2[i] = new Card(str[0],str[1],i);
		}

		BubbleSort(C1);
		C1[N-1].onLast();
		Arrays.asList(C1).forEach(e->e.print());
		System.out.println(isStable(C1));

		SelectionSort(C2);
		C2[N-1].onLast();
		Arrays.asList(C2).forEach(e->e.print());
		System.out.println(isStable(C2));

		scan.close();
	}

	private void BubbleSort(Card[] c) {
		for(int i = 0;i < N;i++) {
			for(int j = N-1; j > i;j-- ) {
				if(c[j].getNum() < c[j-1].getNum()) {
					Card tmp = c[j];
					c[j] = c[j-1];
					c[j-1] = tmp;
				}
			}
		}
	}

	private void SelectionSort(Card[] c) {
		int minj;
		for(int i = 0;i < N;i++) {
			minj = i;
			for(int j = i;j < N;j++) {
				if(c[j].getNum() < c[minj].getNum()) {
					minj = j;
				}
			}
			Card tmp = c[i];
			c[i] = c[minj];
			c[minj] = tmp;
		}
	}

	private String isStable(Card[] c) {
		for(int i = 0 ;i < N-1 ;i++ ) {
			if(c[i].getNum() == c[i+1].getNum() && c[i].getId() > c[i+1].getId()) {
				return "Not stable";
			}
		}
		return "Stable";
	}
}

class Card{
	private int num;
	private String mark;
	private boolean last;
	private int id;

	public Card(String mark,String num,int id) {
		this.num = Integer.parseInt(num);
		this.mark = mark;
		this.id = id;
		last = false;
	}

	public void print() {
		System.out.print(mark + Integer.toString(num) + (last ? "\n" : " " ));
	}

	public int getNum() {
		return num;
	}

	public int getId() {
		return id;
	}

	public void onLast() {
		last = true;
	}
}


Measured memory_bytes: 32348
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 1000000000
#define ldb long double
#define pb push_back
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE ll i=p;i<=n;++i)
#define go(x) for(ll i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE ll i=n;i>=p;--i)
#define pii pair<ll,ll>
#define mk make_pair
#define RE register
#define P 1000000007
#define mod 998244353
#define S second 
#define F first
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define ull unsigned long long
#define ui unsigned
#define zz p<<1
#define yy p<<1|1
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    register ll x=0,f=1;register char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const ll MAXN=250;
map<string,int>H;
string a;
int n;
int main()
{
	//freopen("1.in","r",stdin);
	gt(n);int cnt=0;
	rep(1,n,i)
	{
		cin>>a;
		if(!H[a])++cnt;
		H[a]=1;
	}
	put(cnt);return 0;
}

Measured memory_bytes: 19380
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc051/d.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

ll dist[105][105];
int n;
int edge_l[1005];

void warshall_floyd(){//globalでN * N距離行列 distが存在する前提
    rep(k, n){
        rep(i, n){
            rep(j, n){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                dist[j][i] = dist[i][j];
            }
        }
    }
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int m;
    cin >> n >> m;
    vector<pair<int, int>> edge(m + 1);
    rep(i, n){
        rep(j, n){
            dist[i][j] = INF;
        }
    }
    rep(i, n){
        dist[i][i] = 0;
    }

    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        dist[a][b] = c;
        dist[b][a] = c;
        edge[i] = make_pair(a, b);
        edge_l[i] = c;
    }

    warshall_floyd();

    int ans = 0;
    int flag = 0;
    rep(i, m){
        flag = 0;
        rep(j, n){
            if(flag == 1){
                flag = 0;
                break;
            }
            rep(k, n){
                if(dist[j][k] == dist[j][edge[i].first] + edge_l[i] + dist[edge[i].second][k]){
                    ans++;
                    flag = 1;
                    break;
                }else if(dist[j][k] == dist[j][edge[i].second] + edge_l[i] + dist[edge[i].first][k]){
                    ans++;
                    flag = 1;
                    break;
                }
            }
        }
    }  

    cout << m - ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 5999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


int main() {
	ll a, b ,ans = 1;
	cin >> a >> b;
	if (ABS(a, b) <= 1) {
		REPO(i, a) {
			ans *= i;
			ans %= 1000000007;
		}
		REPO(i, b) {
			ans *= i;
			ans %= 1000000007;
		}
	}
	else {
		cout << 0 << endl;
		return 0;
	}
	if (ABS(a, b) == 0) {
		ans *= 2;
		ans %= 1000000007;
	}
	cout << ans << endl;
}

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();
        sc.close();

        if (a % 2 == 1 && b % 2 == 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <tuple>

using namespace std;

#ifdef ZTDebug
#define In scanf_s
#else
#define In scanf
#endif // ZTDebug

#define Ind(d) In("%d", &d)
#define Ind2(a, b) In("%d%d", &a, &b)
#define InD(d) int d; In("%d", &d);
#define InD2(a, b) int a, b; In("%d%d", &a, &b);
#define InDN(n, v) for (auto _i = 0; _i < n; ++_i) In("%d", &v[_i]);
#define OutDNLine(n, v) for (auto _i = 0; _i < n; ++_i) printf("%d%c", *(v + _i), _i + 1 == n ? '\n' : ' ');

typedef double db;
typedef long long LL;
typedef pair<int, int> pii;

const int Max = 100010;

int fa[Max], xs[Max], ys[Max];
int getFa(int x) { return fa[x] == -1 ? x : fa[x] = getFa(fa[x]); }

bool cmpX(int i, int j) { return xs[i] < xs[j]; }
bool cmpY(int i, int j) { return ys[i] < ys[j]; }

int main() {
#ifdef ZTDebug
    while (true) {
#endif // ZTDebug
        InD(n);
        for (auto i = 0; i < n; ++i) Ind2(xs[i], ys[i]);

        memset(fa, -1, sizeof(fa));
        vector<int> vec;
        for (auto i = 0; i < n; ++i) vec.push_back(i);

        vector<tuple<int, int, int>> edges;
        sort(vec.begin(), vec.end(), cmpX);
        for (auto i = 1; i < n; ++i) edges.push_back(make_tuple(xs[vec[i]] - xs[vec[i - 1]], vec[i], vec[i - 1]));
        sort(vec.begin(), vec.end(), cmpY);
        for (auto i = 1; i < n; ++i) edges.push_back(make_tuple(ys[vec[i]] - ys[vec[i - 1]], vec[i], vec[i - 1]));

        sort(edges.begin(), edges.end());

        auto sum = 0;
        for (auto e : edges) {
            auto fx = getFa(get<1>(e)), fy = getFa(get<2>(e));
            if (fx != fy) {
                fa[fx] = fy;
                sum += get<0>(e);
            }
        }
        cout << sum << endl;
#ifdef ZTDebug
    }
#endif // ZTDebug
    return 0;
}


Measured memory_bytes: 6640
h,w=map(int,input().split())
meize=[list(input()) for i in range(h)]
mod=10**9+7

dp=[[0]*(1+w) for i in range(1+h)]

dp[0][1]=1
for i in range(h):
  for j in range(w):
    if meize[i][j]=='#':
      dp[i+1][j+1]=0
    else:
      dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
      dp[i+1][j+1]%=mod

print(dp[h][w]%mod)

Measured memory_bytes: 51496
#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() {
    ll a, b;
    cin >> a >> b;
    ll ans = max(a+b, a-b);
    ans = max(ans, a*b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
function Main(input){
var inputs = input.split(" ");
var answer;
if(inputs[1] == "+"){
  answer =new Number( inputs[0]) +new Number( inputs[2]);
}else if(inputs[1] == "-"){
  answer =new Number(inputs[0]) - new Number( inputs[2]);
}
console.log(answer);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
alpha = {1:'A', 2:'B', 3:'C', 4:'D', 5:'E', 6:'F', 7:'G', 8:'H', 9:'I', 10:'J', 11:'K', 12:'L', 13:'M', 14:'N', 15:'O', 16:'P', 17:'Q', 18:'R', 19:'S', 20:'T', 21:'U', 22:'V', 23:'W', 24:'X', 25:'Y', 26:'Z'}
h, w = map(int, input().split())
for i in range(h):
  a = list(input().split())
  for j in range(w):
    if a[j] == 'snuke':
      ans = alpha[j+1] + str(i+1)
      break
print(ans)


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

int main() {
    int H, N;
    int A[100010];
    cin >> H >> N;
    for (int i = 0;i < N;i++){
        cin >> A[i];
    }
    for (int i = 0;i < N;i++){
        H -= A[i];
    }
    if(H <= 0)
    cout << "Yes" << endl;
    else
    cout << "No" <<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <tuple>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<tuple<int64_t, int64_t, int64_t>> vs(n);
    for (auto& v : vs)
    {
        int64_t a, b;
        cin >> a >> b;
        int64_t d = a + b;
        v = make_tuple(d, a, b);
    }
    sort(vs.begin(), vs.end(), greater<>());

    int64_t sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            sum += get<1>(vs[i]);
        }
        else
        {
            sum -= get<2>(vs[i]);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(){
  long n,m,a,total=0;
  int i,j,k;
  
  scanf("%ld %ld",&n,&m);
  for(i=0;i<m;i++){
    scanf("%ld",&a);
    total+=a;
  }
  
  if(n-total<0){
    printf("-1");
  } else {
    printf("%ld",n-total);
  }
}  


Measured memory_bytes: 1732