akhauriyash/Code-Regression huggingface dataset:
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
const LL MO = 1e9 + 7, MAXN = 100000 + 5;
LL cf[MAXN], n, dp[MAXN][15];
char s[MAXN];
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	cf[0] = 1;
	for (LL i = 1; i <= n; ++i) cf[i] = cf[i - 1] * 10 % 13;
	if (s[n] == '?') {
		for (LL j = 0; j <= 9; ++j) dp[n][j] = 1;
	} else dp[n][s[n] - '0'] = 1;
	for (LL i = n; i >= 1; --i) 
	for (LL j = 0; j < 13; ++j) {
		if ('0' <= s[i - 1] && s[i - 1] <= '9') {
			(dp[i - 1][(j + cf[n - i + 1] * (s[i - 1] - '0') % 13) % 13] += dp[i][j]) %= MO;
		} else {
			for (LL c = 0; c <= 9; ++c) {
				(dp[i - 1][(j + cf[n - i + 1] * c % 13) % 13] += dp[i][j]) %= MO;
			}
		}
	}
	cout << dp[1][5];
	return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

int main()
{
  int n;
  cin >> n;
  cout << (((n - 1) / 1000 + 1) * 1000 - n) << endl;
}

Measured memory_bytes: 3680
#include <stdio.h>
#define NUMBER 3
void bsort(int a[], int n)
{
    int i,j;
    for (i=0; i<n-1; i++){
        for(j=n-1; j>i; j--){
            if(a[j-1]>=a[j]){
                int temp=a[j];
                a[j]=a[j-1];
                a[j-1]=temp;
    
            }
        }
    }
}
int main(void){
    // Your code here!
    int i;
    int x[NUMBER];
    
    for(i=0; i<NUMBER; i++){
        scanf("%d", &x[i]);
    }
    
 bsort(x,NUMBER);
 i=0;
    
    printf("%d %d %d\n", x[i],x[i+1],x[i+2]);
    
    return 0;
}



Measured memory_bytes: 2100
#include<stdio.h>
#include<string.h>

#define Len 14
#define N 999997

char H[N][Len]; 

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}


long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%N; }
int h2(int key){ return 1+(key%(N-1)); }

int find(char str[]){
  int a=0,k=0;
  long long sum;
  sum=getKey(str);

  while(1){
    k=(h1(sum)+a*h2(sum))%N;
    if(H[k][0]=='\0' || a==N){
      return 0;
    }
    if(strcmp(H[k],str)==0){
      return 1;
    }
    else a++;
  }

}

void insert (char str[]){
  int b=0,k=0;
  long long sum;
  sum=getKey(str);
  while(b!=N){
    k=(h1(sum)+b*h2(sum))%N;
    if(H[k][0]=='\0'){
      strcpy(H[k],str);
      break;
    }
    else b++;
    
  }
}



int main(){
    int i, n, h;
    char str[Len], com[9];
    for ( i = 0; i < N; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
#include<bits/stdc++.h>
using namespace std;
bool odd(char ch)
{
    if(ch == 'R' || ch == 'U' || ch == 'D')
    {
        return true;
    }
    else
    {
        return false;
    }
}
bool even(char ch)
{
    if(ch == 'U' || ch == 'D' || ch == 'L')
    {
        return true;
    }
    else
    {
        return false;
    }
}
int main()
{
    string st;
    cin >> st;
    for(int i = 0; i < st.length(); i++)
    {
        if((i+1) % 2 == 0)
        {
            bool ok = even(st[i]);
            if(ok == false)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            bool ok = odd(st[i]);
            if(ok == false)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define ld          long double
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

void solve() {
    int x; cin >> x;
    int tot = (x / 500) * 1000;
    int rem = x % 500;
    tot += (rem / 5)*5;
    cout << tot << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;
    for(int tt=1; tt<=T; tt++) {
    	solve();
    }
    return 0;
}

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


int main (void){
  int n;
  int a,b,s = 0;
  cin >> n;

  for(int i = 0;i < n;i++){
    cin >> a >> b;
    if(a == b){
      s++;
      if(s == 3){
        cout << "Yes" << endl;
        return 0;
      }
    }else{
      s = 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
int cnt[200000] = {};
void solve() {
	int n, h, w;
	cin >> n >> h >> w;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		int now = i * w;
		if (i % 2 == 0) {
			now += a;
		}
		else {
			now -= a;
		}
		cnt[now]++;
		cnt[now + w]--;
	}
	int ans = 0;
	REP(i, w* n) {
		cnt[i + 1] += cnt[i];
		if (cnt[i] == 0) {
			ans++;
		}
	}
	cout << ans * h << endl;
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
# define ll long long int
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll n;
    cin>>n;
    ll a[n],ans=INT_MAX;
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=1;i<=100;i++){
    	ll sum=0;
    	for(ll j=0;j<n;j++){
    		sum+=abs(i-a[j])*abs(i-a[j]);
		}
		ans=min(ans,sum);
	}
	cout<<ans;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Data.List
import           Data.Bits

input :: IO [Int]
input = do
    d <- (fst . fromJust) . BS.readInt <$> BS.getLine
    map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine

process :: [Int] -> Integer
process [] = 0 :: Integer
process (x:xs) =  (shift 1 x) .|. process xs   

main :: IO ()
main = do
    [n,k] <- map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine
    ass <- replicateM k input
    putStr $ show $ result n ass 
    where
        hammingWeight ass = popCount $ convoluton (map process ass) 
        result n ass = n - hammingWeight ass
        convoluton = foldl (.|.) (0::Integer)


Measured memory_bytes: 4992
#include <stdio.h>
#define MAX 2000000

int n, A[MAX + 1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= n && A[r] > A[largest]) largest = r;

  if (largest != i) {
    //swap
    int x = A[i];
    A[i] = A[largest];
    A[largest] = x;
    maxHeapify(largest);
  }

}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }

  for (int i = n / 2; i >= 1; i--) {
    maxHeapify(i);
  }

  for (int i = 1; i <= n; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;cin >> N;
    vector<ll> a(N),b(N);
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++) cin >> b[i];

    ll dif=0;
    for(int i=0;i<N;i++){
        if(a[i]>b[i]) dif+=b[i]-a[i];
        else dif+=(b[i]-a[i])/2;
    }
    cout << (dif>=0?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 384
N, M = [int(x) for x in input().split()]
ans = 0
permN = 1
permM = 1

for i in range(N):
	permN = permN * (i + 1) % (10 ** 9 + 7)
for i in range(M):
	permM = permM * (i + 1) % (10 ** 9 + 7)

if abs(N - M) > 1:
	ans = 0
elif abs(N - M) == 1:
	ans = permN * permM % (10 ** 9 + 7)
else:
	ans = 2 * permN * permM % (10 ** 9 + 7)

print(ans)

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

using namespace std;

int main(int argc, char *argv[]) {
  int nums[5];

  for (int i = 0; i < 5; i++)
    cin >> nums[i];

  sort(nums, nums + 5);

  for (int i = 0; i < 5; i++) {
    cout << nums[4 - i];
    if (i == 4)
      cout << endl;
    else
      cout << ' ';
  }
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    ll s = 0, ok = 1;
    vll a(n), b(n) ,d(n);
    REP(i, n) cin >> a[i];
    REP(i, n){
        cin >> b[i];
        d[i] = a[i] - b[i];
        s += d[i];
        if(d[i] < 0) ok = 0;
    }
    if(ok){
        cout << 0 << endl;
        return 0;
    }
    if(s < 0){
        cout << -1 << endl;
        return 0;
    }
    VSORT(d);
    ll up = n - 1, res = 0;
    vll used(n);
    REP(i, n){
        //余裕のある方から順に足りないところに回す
        if(d[i] < 0) res++; //不足側の変更
        else break;
        while(d[i] < 0){
            if(!d[up]) up--;
            if(!used[up]){
                res++; //譲渡側の変更
                used[up] = 1;
            }
            ll fill = min(-d[i], d[up]);
            d[i] += fill;
            d[up] -= fill;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3328
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

dp=[[[0,1000],[0,1000]] for i in range(N+1)]


def wa(lis,a):
    return lis[0]*a+lis[1]

for i in range(N):
    #0が株売り　1が株買い
    dp[i+1][0]=dp[i][0] if wa(dp[i][0],A[i])>=wa(dp[i][1],A[i]) else [0,dp[i][1][0]*A[i]+dp[i][1][1]]
    #株が多くなるように買う
    dp[i+1][1]=dp[i][1] if wa(dp[i][1],A[i])>wa(dp[i][0],A[i]) else [dp[i][0][1]//A[i],dp[i][0][1]-dp[i][0][1]//A[i]*A[i]]
    
    
print(dp[-1][0][-1])


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
int a[maxn], mini = 1e9;
int main(){
	long long s = 0;
	int n, neg = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		mini = min(abs(x), mini);
		if (x < 0)
			neg ++;
		s += abs(x);
	}
	if(neg % 2 == 0)
		cout << s;
	else
		cout << s - (2 * mini);
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main(){
  string s;
  cin >> s;
  bool flag=true;
  for(int i=0;i<s.length();i++){
    if(i%2 != 0){
      if(s[i] == 'R'){
        flag=false;
        break;
      }
    }
    else{
      if(s[i] == 'L'){
        flag=false;
        break;
      }
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int N = 100010;
const int INF = 19191919;

vector<int> G[N];
int d[N][3];

int main(){
    int n,m;
    scanf(" %d %d", &n, &m);

    rep(i,m){
        int u,v;
        scanf(" %d %d", &u, &v);
        --u;
        --v;
        G[u].pb(v);
    }

    int s,t;
    scanf(" %d %d", &s, &t);
    --s;
    --t;

    rep(i,N)rep(j,3) d[i][j] = INF;
    d[s][0] = 0;
    queue<pi> que({{s,0}});
    while(!que.empty()){
        pi v = que.front();
        que.pop();

        int D = d[v.fi][v.se];
        int nx = (v.se+1)%3;

        for(int e:G[v.fi]){
            if(d[e][nx] > D+1){
                d[e][nx] = D+1;
                que.push({e,nx});
            }
        }
    }

    int ans = -1;
    if(d[t][0]<INF) ans = d[t][0]/3;
    printf("%d\n",ans);
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

using Graph = V<V<int>>;

int main() {
    int n, m; cin >> n >> m;
    Graph g(n + 1);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    V<int> parent(n + 1, -1);
    queue<int> que;

    parent[1] = 0;
    que.push(1);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int nv : g[v]){
            if(parent[nv] != -1) continue;
            parent[nv] = v;
            que.push(nv);
        }
    }

    for(int i = 2; i <= n; i++){
        if(parent[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 2; i <= n; i++){
        cout << parent[i] << endl;
    }

}


Measured memory_bytes: 10160
N,M=map(int,input().split())
necess=list(map(int,input().split()))

min_time=0
for i in range(M):
    min_time=min_time+necess[i]
    # print(i)

if(N<min_time):
    print(-1)
else:
     print(N-min_time)   

Measured memory_bytes: 9884
n = input()
S = ['S 1','S 2','S 3','S 4','S 5','S 6','S 7','S 8','S 9','S 10','S 11','S 12','S 13']
H = ['H 1','H 2','H 3','H 4','H 5','H 6','H 7','H 8','H 9','H 10','H 11','H 12','H 13'] 
C = ['C 1','C 2','C 3','C 4','C 5','C 6','C 7','C 8','C 9','C 10','C 11','C 12','C 13']
D = ['D 1','D 2','D 3','D 4','D 5','D 6','D 7','D 8','D 9','D 10','D 11','D 12','D 13']
cards=[S,H,C,D]

for i in range(n):
  exist = raw_input()
  if 'S' in exist:
    cards[0].remove(exist)
  if 'H' in exist:
    cards[1].remove(exist)
  if 'C' in exist:
    cards[2].remove(exist)
  if 'D' in exist:
    cards[3].remove(exist)

for j in range(4):
  for i in cards[j]:
    print i

Measured memory_bytes: 6392
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int C[200000];
	rep(i, N) C[i] = getint();
	pakuri_sort(N, C);

	ll kotae = 0;
	int n = N / 2000;
	int m = N % 2000;
	int k = 0;
	rep(i, n) {
		rep(j, 2000) kotae += ll(N + 1 - k) * C[k++];
		kotae %= mod;
	}
	rep(i, m) kotae += ll(N + 1 - k) * C[k++];

	printf("%lld\n", kotae % mod * modpow(2, N + N - 2) % mod);




	Would you please return 0;
}

Measured memory_bytes: 1792
/*
 * FileName:     bit_mask_fix
 * CreatedDate:  2020-07-27 20:25:33 +0900
 * LastModified: 2020-07-27 21:08:57 +0900
 */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    long unsigned int bit = 0;
    int n;scanf("%d", &n);
    long unsigned int *box = malloc(n*sizeof(long unsigned int));
    for(int i=0; i<n; i++){
        int k;scanf("%d", &k);
        for(int j=0; j<k; j++){
            int b;scanf("%d", &b);
            box[i] += 1UL<<b;
        }
    }
    int q;scanf("%d", &q);
    for(int i=0; i<q; i++){
        int command, m;scanf("%d%d", &command, &m);
        if( command==0 ){
            printf("%lu\n", 1&bit>>m);
        }
        else if( command==1 ){
            bit |= box[m];
        }
        else if( command==2 ){
            bit &= ~box[m];
        }
        else if( command==3 ){
            bit ^= box[m];
        }
        else if( command==4 ){
            if( (bit&box[m])==box[m] ){
                printf("1\n");
            }
            else{
                printf("0\n");
            }
        }
        else if( command==5 ){
            if((bit&box[m])==0){
                printf("0\n");
            }
            else{
                printf("1\n");
            }
        }
        else if( command==6 ){
            printf("%d\n", !(bit&box[m]));
        }
        else if( command==7 ){
            printf("%d\n", __builtin_popcountll(bit&box[m]));
        }
        else{
            printf("%lu\n", bit&box[m]);
        }
    }
    free(box);
    return 0;
}



Measured memory_bytes: 2136
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

const int maxN = 100005;
const int INF = 1000000000;

int x[maxN], y[maxN];
char d[maxN];

double max(double a, double b) {
  return a > b ? a : b;
}
double min(double a, double b) {
  return a < b ? a : b;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %c", &x[i], &y[i], &d[i]);
  }

  double l = 0, r = 200000000;
  double ans = (1ll << 62);
  for (int k = 0; k < 1000; k++) {
    double m1 = (2*l + r) / 3;
    double m2 = (l + 2*r) / 3;
    double eval1, eval2;
    double _x = INF, _X = -INF, _y = INF, _Y = -INF;
    double __x = INF, __X = -INF, __y = INF, __Y = -INF;
    for (int i = 0; i < n; i++) {
      double x_ = x[i], y_ = y[i];
      double x__ = x[i], y__ = y[i];
      if (d[i] == 'R') {
        x_ += m1;
        x__ += m2;
      } else if (d[i] == 'L') {
        x_ -= m1;
        x__ -= m2;
      } else if (d[i] == 'U') {
        y_ += m1;
        y__ += m2;
      } else if (d[i] == 'D') {
        y_ -= m1;
        y__ -= m2;
      }
      _x = min(_x, x_);
      _X = max(_X, x_);
      _y = min(_y, y_);
      _Y = max(_Y, y_);
      __x = min(__x, x__);
      __X = max(__X, x__);
      __y = min(__y, y__);
      __Y = max(__Y, y__);
    }
    eval1 = (_X - _x) * (_Y - _y);
    eval2 = (__X - __x) * (__Y - __y);
    if (eval1 < eval2) {
      ans = eval1;
      r = m2;
    } else {
      ans = eval2;
      l = m1;
    }
  }
  printf("%f\n", ans);
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
using namespace std;
typedef long long int ll;
int main()
{
    int n;
    cin>>n;
    if(n%2==0 || n%5==0){
        cout<<"-1";
        return 0;
    }
    int ct=1;
    int val = 7;
    while(val%n!=0)
    {
        ct++;
        val = (val*10+7)%n;
    }
    cout<<ct<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int a, b, c, i, j, k, n, ans = 0, r;
	cin >> a >> b >> c >> n;
	for (i = 0; i * a <= n; i++) {
		for (j = 0; j * b + i * a <= n; j++) {
			r = n - (j * b + i * a);
			if (r % c == 0) ans++;
		}
	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long

using namespace std;

int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

signed main(){
    int k, sum=0;
    //nums.resize(n);
    cin >> k;
    for(int i1=1;i1<=k;i1++){
        for(int i2=1;i2<=k;i2++){
            for(int i3=1;i3<=k;i3++){
                sum+=gcd(i1, gcd(i2, i3));
            }
        }
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(){
	int n,i,j;
	int s[150];
	int s2[159];
	int same=0;
	int result=0;
	int min;
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d\n",&s[i]);
	}
	for(i=0;i<=100;i++)
	{
		s2[i]=0;
	}

	
	for(i=0;i<n;i++)
	{
	for(j=1;j<=100;j++)
	{
		if(s[i]==j){
			s2[j]++;
	}
	}
	}
	result=0;
	for(i=1;i<=100;i++)
	{
		if(s2[i]!=0){
			result++;}
	}
	printf("%d",result);
	return 0;
	}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int H, W;
   cin >> H >> W;
   cout << string(W+2, '#') << endl;
   rep (i, H) {
      string s;
      cin >> s;
      cout << "#" + s + "#" << endl;
   }
   cout << string(W+2, '#') << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n;
    cin >> n;
    deque<int> q;

    rep(i, n) {
        int a;
        cin >> a;
        if(i%2==0) {
            q.push_back(a);
        } else {
            q.push_front(a);
        }
    }

    if(n%2) {
        rep(i, n) cout << q[q.size()-1-i] << " ";
    } else {
        rep(i, n) cout << q[i] << " ";
    } cout << endl;
    
    return 0;
}

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

#define lli long long int
#define REP(i, s, l) for (lli i = s; i < l; i++)
#define DEBUG 0
#define INF (1LL << 50)
#define MOD 1000000007

int main()
{
    string s1, s2, s3;

    cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[1] << s3[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input, marker::*};
use std::collections::*;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;

#[fastout()]
fn main() {
    input! {
        H:usize,W:usize,K:usize,
        C:[Chars;H]
    }
    let mut tateblack = vec![0; H];
    let mut yokoblack = vec![0; W];
    let mut totalblack = 0;
    for h in 0..H {
        for w in 0..W {
            tateblack[h] = tateblack[h] + if C[h][w] == '#' { 1 } else { 0 };
            yokoblack[w] = yokoblack[w] + if C[h][w] == '#' { 1 } else { 0 };
        }
        totalblack += tateblack[h];
    }
    let mut tate = vec![false; H];
    let mut yoko = vec![false; W];
    let mut ans = 0;
    //println!("tate {:?}", tateblack);
    //println!("yoko {:?}", yokoblack);
    for hbin in 0..2u32.pow(H as u32) {
        for i in 0..H {
            tate[i] = hbin >> i & 1 == 1;
        }
        for wbin in 0..2u32.pow(W as u32) {
            let mut cnt = 0;
            for i in 0..W {
                yoko[i] = wbin >> i & 1 == 1;
            }
            for h in 0..H {
                if tate[h] {
                    cnt += tateblack[h];
                }
            }
            for w in 0..W {
                if yoko[w] {
                    cnt += yokoblack[w];
                }
                for h in 0..H {
                    if tate[h] && yoko[w] && C[h][w] == '#' {
                        cnt -= 1;
                    }
                }
            }
            //println!("h={:?},w={}, {:?},{}", tate, wbin, yoko, cnt);
            if totalblack == K + cnt {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);


vll nums={2,3,5};

ll f(){
  ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  vll costs = {a,b,c};
  priority_queue<ll> pq;
  pq.push(n);
  ll ans = 1e18;
  unordered_map<ll,ll> mp;
  while(1){
    ll cur = pq.top();
    pq.pop();
    ll score = mp[cur];
    if(log(d) + log(cur) <= log(1e18)){
      ans = min(ans, score + d * cur);
    }
    if(cur == 1){
      return ans;
    }
    for(int i=0;i<3;i++){
      ll tmp1 = cur / nums[i];
      ll score1 = score +  d *(cur - tmp1 * nums[i]) + costs[i];
      ll tmp2 = tmp1 + 1;
      ll score2 = score + d * (tmp2 *nums[i] - cur) + costs[i];
      if(mp.find(tmp1) != mp.end()){
        mp[tmp1] = min(mp[tmp1], score1);
      }else{
        mp[tmp1] = score1;
        pq.push(tmp1);
      }
      if(mp.find(tmp2) != mp.end()){
        mp[tmp2] = min(mp[tmp2], score2);
      }else{
        mp[tmp2] = score2;
        pq.push(tmp2);
      }
    }
  }
}

int main(){
  ll t;
  cin >> t;
  vector<ll> ans;
  REP(i,1,t){
    ans.push_back(f());
  }
  for(auto x:ans){
    cout << x << endl;
  }
}

Measured memory_bytes: 4396
#include <iostream>
#include <map>

using namespace std;

int main(){
  int N;
  map<int, int> a;
  cin >> N;
  for(int i = 0; i < N; i++){
    int tmp = 0;
    cin >> tmp;
    a[tmp]++;
  }
  int cnt = 0;
  for(auto itr = a.begin(); itr != a.end(); itr++){
    int key = itr->first;
    int value = itr->second;
    if(key > value) cnt += value;
    else if(key < value) cnt += value - key;
  }
  cout << cnt;
}


Measured memory_bytes: 4736
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

#define MAX_NUM_COINS 20
#define MAX_PRICE 50000
#define CALC_MIN(a, b) (a < b ? a : b)

int coin[MAX_NUM_COINS];
int memo[MAX_NUM_COINS][MAX_PRICE+1];

int is_less_than(const void* a, const void* b)
{
  return *(int*)a < *(int*)b;
}

int solve_sub_question(int index, int num_coin, int price)
{
  if(memo[index][price] != -1) {
    return memo[index][price];
  }
  if(index == num_coin - 1) {
    memo[index][price] = price;
    return price;
  }
  if(price % coin[index] == 0) {
    memo[index][price] = price / coin[index];
    return price / coin[index];
  }
  int ans = INT_MAX;
  for(int i = 0; i <= price / coin[index]; i++) {
    int total_coin = i;
    int current_price = price - coin[index] * i;
    total_coin += solve_sub_question(index + 1, num_coin, current_price);
    ans = CALC_MIN(total_coin, ans);
  }
  memo[index][price] = ans;
  return ans;
}

int main()
{
  memset(memo, -1, sizeof(memo));
  for(int i = 0; i < MAX_NUM_COINS; i++) {
    memo[i][0] = 0;
  }

  int price, num_coin;
  scanf("%d%d", &price, &num_coin);
  for(int i = 0; i < num_coin; i++) {
    scanf("%d", &coin[i]);
  }
  qsort(coin, num_coin, sizeof(int), is_less_than);

  printf("%d\n", solve_sub_question(0, num_coin, price));
  return 0;
}



Measured memory_bytes: 6652
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n, order, i;
	map<int, int> a;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> order;
		a.emplace(order -1, i + 1);
	}

	for (i = 0; i < n; i++) {
		cout << a[i] << endl;
	}

	return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string w){
  map<char, long long> tab;

  REP(i, w.size()) {
    tab[w[i]]++;
  }

  bool isAll = true;

  REP(i, ('z' - 'a')) {
    if((tab[('a'+i)] % 2) != 0) isAll = false;
  }

  cout << (isAll ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string w;
  std::cin >> w;
    solve(w);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n,k;
  cin >> n >> k;
  cout << ((n+1)/k>=2?"YES":"NO") << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;


int main(void){
        double a,b;
        double h,m;
        cin >> a >> b >> h >> m;
    // cout << a << b << h << m << endl;
   //     double pi=3.14159265;

        m = 60*h + m;
        double angle;
        angle = M_PI * 11 * m / 360;

        double ans;
        ans = a*a + b*b - 2*a*b*cos(angle);
        ans = sqrt(ans);
        
        cout << setprecision(16) << ans << endl;

        return 0;
}


Measured memory_bytes: 4288
#include <cstdio>

int H;
void maxHeapify(int A[], int i) {
	int l = 2 * i;
	int r = 2 * i + 1;

	int largest = i;
	if (l <= H && A[l] > A[i])
		largest = l;

	if (r <= H && A[r] > A[largest])
		largest = r;

	if (largest != i) {
		int t = A[i];
		A[i] = A[largest];
		A[largest] = t;
		maxHeapify(A, largest);
	}
}

void buildMaxHeap(int A[]) {
	for (int i = H / 2; i >= 1; --i)
		maxHeapify(A, i);
}

int main() {
	int A[500001];
	scanf("%d", &H);
	for (int i = 1; i <= H; ++i)
		scanf("%d", &A[i]);
	buildMaxHeap(A);
	for (int i = 1; i <= H; ++i)
		printf(" %d", A[i]);
	printf("\n");
	return 0;
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

// from x*(A+B) to x*(A+B) + A its all blue for all x >= 0
typedef long long int ll;

void solve(){
	ll N, A, B;
	cin >> N >> A >> B;
	
	ll x = N/(A+B);
	ll ans = A*x;
	ans += min(N-x*(A+B), A);
	
	cout << ans << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}




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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    if (abs(x - a) < abs(x - b))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "B" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{    
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b>=c ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import re
n = int(input())
a = 0
b = 0
ab = 0
cnt = 0
for i in range(n):
    s = input()

    tmp = re.findall(r'AB',s)
    ab += len(tmp)

    if s[0] == "B":
        b += 1
    if s[-1] == "A":
        a += 1
    if s[0] == "B" and s[-1] == "A":
        cnt += 1 
if a == b and a == cnt and a > 0:
    print(a-1+ab)
else:
    print(min(a,b)+ab)

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

const int N = 2e5+10;
int a[N],b[N];

int main(){
	int n,k;
	cin>>k>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n-1;i++)
		b[i] = a[i+1]-a[i];
	b[n-1] = a[0]-a[n-1]+k;
	int maxx = b[0];
	for(int i=1;i<n;i++)
		maxx = max(maxx,b[i]);
	cout<<k-maxx<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
long long s[100010];
int a[100010];
vector<int> p;
map<long long, int> m;
map<long long, int> sq;
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &s[i]);
	}
	for (int i = 2; i < 100010; i++) {
		if (a[i]) continue;
		sq[(long long)i * i] = i;
		p.push_back(i);
		for (int j = i + i; j < 100010; j += i) {
			a[j] = 1;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		long long x = s[i], y = 1, z = 1;
		for (int j = 0; j < p.size(); j++) {
			if (x == 1) break;
			if (p[j] > 2500) {
				break;
			}
			if (x % p[j] == 0) {
				int c = 0;
				while (x % p[j] == 0) {
					++c;
					x /= p[j];
				}
				c %= 3;
				if (c == 1) {
					y *= p[j];
					y *= p[j];
					z *= p[j];
				} else if (c == 2) {
					y *= p[j];
					z *= p[j];
					z *= p[j];
				}
			}
		}
		if (x * z == 1) {
			m[1] = 1;
		} else if (sq.count(x)) {
			z *= x;
			y *= sq[x];
			m[z]++;
			if (m[z] > m[y]) {
				ans++;
			}
		} else {
			if (x * x < 10000000000ll / y) {
				z *= x;
				m[z]++;
				y *= x * x;
				if (m[z] > m[y]) {
					ans++;
				}
			} else {
				ans++;
			}
		}
	}
	printf("%d\n", ans + !!m[1]);
	return 0;
}


Measured memory_bytes: 11264
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = [(int(input()), i) for i in range(N)]
    A.sort(reverse=True)
    for i in range(N):
        if A[0][1] == i:
            print(A[1][0])
        else:
            print(A[0][0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 63184
#include<stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define INF (int)1e9
#define MIN(a,b) (((a)<(b)) ? (a):(b))

int main(){
	int n,m,a[1002],b[1002],c[1002],root[102][102];

	FOR(i,0,102){
		FOR(j,0,102){
			if(i == j) root[i][j] = 0;
			else root[i][j] = INF;
		}
	}

	scanf("%d %d",&n,&m);
	FOR(i,0,m){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		root[a[i]][b[i]] = c[i];
		root[b[i]][a[i]] = c[i];
	}

	FOR(k,1,n+1)	//中継点
		FOR(i,1,n+1)	//始点
			FOR(j,1,n+1)	//終点
				root[i][j] = MIN(root[i][j],root[i][k]+root[k][j]);

	int ans = m;

	FOR(k,0,m)	//判定する辺
			FOR(i,1,n+1)	//始点
				if(root[i][a[k]] + c[k] == root[i][b[k]]){	//最短経路に使用済み
					ans--;
					break;
				}

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

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

int main(){

    int N;
    cin >> N;
    vector<int> H(N+1);
    rep (i, N) cin >> H[i];

    bool frag = true;
    int maxi = 0;
    rep (i, N){
        if (maxi <= H[i] || maxi - 1 <= H[i]){
            maxi = max(maxi, H[i]);
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>

int main(void){
    int i,l,cnt=0;
    char s[100001];
    scanf("%s",s);
    l = strlen(s);
    for(i=0;i<l;i++){
        if(s[i]=='0'+i%2)cnt++;
    }
    printf("%d\n",std::min(cnt,l-cnt));
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
 
using namespace std;

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  
  vector<int> H(N);
  for (auto &i : H) cin >> i;
  
  int min_point;
  double value;
  double min_value = 1000;
  for (int i=0; i<N; i++) {
    value = abs(T - H[i]*0.006 - A);
    if (value < min_value) {
      min_point = i+1;
      min_value = value;
    }
  }
  cout << min_point << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int x , a, b; cin >> x>> a >> b;
	if (b <= a) {
		cout << "delicious" << endl;
	}
	else if (b <= a + x) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	string S;
	cin >> S;
	vb ans(4, false);

	for (auto s : S)
		if (s == 'N') ans[0] = true;
		else if (s == 'W') ans[1] = true;
		else if (s == 'E') ans[2] = true;
		else if (s == 'S') ans[3] = true;

	if (ans[0] && ans[1] && ans[2] && ans[3]) {
		cout << "Yes" << endl;
	}
	else if (ans[0] && !ans[1] && !ans[2] && ans[3]) {
		cout << "Yes" << endl;
	}
	else if (!ans[0] && ans[1] && ans[2] && !ans[3]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

int main () {
  ll t = 1;
//   cin >> t;
  while(t--){
    string s;
    cin >> s;
    ll cnt = 0;
    for(ll i =0 ;i < 3;i++){
        if(s[i] == '1'){
            cnt++;
        }
    }
    cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i , n , result;
		Scanner sc = new Scanner(System.in);
		while ( sc.hasNext() ) {
			i = sc.nextInt();
			result = 2;
			for ( n = 2; n <= i; n++ )
				result += n;
			System.out.printf("%d\n",result);
		}
	}
}

Measured memory_bytes: 0