akhauriyash/Code-Regression huggingface dataset:
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
ll dp[105][N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,W;
        cin>>n>>W;
        ll w[n+3],v[n+3];
        for(int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
        for(int i=1;i<=n;i++)
        {
        	for(int j=1;j<=W;j++)
        		dp[i][j]=dp[i-1][j];
        	dp[i][w[i]]=v[i];
        	for(int j=1;j<=W;j++)
        	{
        		if(j+w[i]<=W&&dp[i-1][j]>0)
        		{
        			dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i-1][j]+v[i]);
        		}
        	}
        }
        ll ans=0;
        for(int i=0;i<=W;i++)
        {
        	ans=max(ans,dp[n][i]);
        }
        cout<<ans;

    }
    return 0;
}

Measured memory_bytes: 79360
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

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


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

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> c(N), t(N);
  for (int i = 0; i < N; ++i) {
    cin >> c[i] >> t[i];
  }
  int ans = 1000000001;
  for (int i = 0; i < N; ++i) {
    if (t[i] <= T) {
      ans = min(c[i], ans);
    }
  }

  if (ans == 1000000001) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

import bisect

def main(N,A,B,C):
    A.sort()
    C.sort()
    ans = 0
    for i in B:
        cnt_small = bisect.bisect_left(A,i)
        cnt_large = N - bisect.bisect_right(C,i)
        ans += cnt_small*cnt_large
    print(ans)
        
if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    main(N,A,B,C)

Measured memory_bytes: 23232
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
#define index Index
using namespace std;
const int inf=1e9+10;
const ll llinf=1e17+10;
const int maxn=1e5+10;
const int maxm=1e1+10;
const int mod=1e9+7;
int n,m;
vector<int> v[maxn];
int vis[maxn];
int pre[maxn];
int solve(int x)
{
    if(vis[x]==1) return 0;
    vis[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
        int to=v[x][i];
        if(pre[to]==-1||solve(pre[to]))
        {
            pre[to]=x;
            return 1;
        }
    }
    return 0;
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        pair<int,int> red[maxn];
        pair<int,int> blue[maxn];
        for(int i=1;i<=n;i++)
        {
            int x,y;
            v[i].clear();
            scanf("%d %d",&x,&y);
            red[i]=mp(x,y);
        }
        for(int i=1;i<=n;i++)
        {
            int x,y;
            scanf("%d %d",&x,&y);
            blue[i]=mp(x,y);
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(red[i].fs<blue[j].fs && red[i].sc<blue[j].sc)
                {
                    v[i].pb(j);
                }
            }
        }
        cls(pre,-1);
        for(int i=1;i<=n;i++)
        {
            cls(vis,0);
            solve(i);
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            if(pre[i]!=-1)
                ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    ll l,r;
    cin>>l>>r;
    bool ok=true;
    int a=l/2019;
    int b=r/2019;
    if(b!=a)ok=false;
    if(l%2019==0||r%2019==0)ok=false;
    if(!ok){
        cout<<0<<endl;
        return 0;
    }
    ll ans=INF;
    for(ll i=l;i<r;i++){
        for(ll j=l+1;j<=r;j++){
            ans=min(ans,(i*j)%2019);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
s = list(input())
k = int(input())
n = len(s)
substring = []

for i in range(n):
    tmp = ""
    for l in s[i:i + k:]:
        tmp += l
        if tmp in substring:
            continue

        else:
            substring.append(tmp)

substring.sort()

print(substring[k - 1])


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,a,size,oddcount=0,evencount=0;
    string s,ans;

    cin>>s;

    ans="2018";

    for(int i=4;i<s.size();i++){
        ans=ans+s[i];
    }

    cout<<ans<<endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int n,t,b,c,ans,max1;
int main(){
	cin>>n>>t;

	for(int i=0;i<=n-1;i++) cin>>a[i];
	b=a[0];
	max1=-100;	
	for(int i=1;i<=n-1;i++)
	{    
		if(a[i]>b) 
		{
		    c=a[i]-b;
			if(c==max1) 
			    ans++;
			    
			else 
			  if(c>max1)
			    {max1=c;ans=1;}
		}
		else 
		   b=a[i]; 
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;

int max(int a, int b) { return (a > b) ? a : b; }

const int MAXN = 100000;

int a[MAXN];
int b[MAXN];


const int INF = 1e9;

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

    int n;
    cin >> n;
    vector<pair<int, int>> v;
    v.reserve(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        v.emplace_back(a[i] + b[i], i);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int i = 1;
    ll ans = 0;
    for (auto& p : v)
    {
        if (i == 1)
        {
            ans += a[p.second];
            i = 0;
        } else
        {
            i = 1;
            ans -= b[p.second];
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
n, m = gets.chomp.split.map(&:to_i)
ary = gets.chomp.split.map(&:to_i)
ary.shift
(n-1).times do
    tmp = gets.chomp.split.map(&:to_i)
    tmp.shift
    # p tmp
    ary = ary & tmp
end

puts ary.length

# count = 0
# n.times do |i|
#     if ary.count(i) == m
#         count += 1
#     end
# end

# puts count

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

using namespace std;

const int MAXN = (int) 1e5;
int a[MAXN];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + 2 * n);
  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    ans += a[i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn=3050;
const int maxm=3050;
const ll MOD=998244353;
ll dp[maxn][maxm];
int a,b,c,d;

void solve(){
	scanf("%d %d %d %d",&a,&b,&c,&d);
	for(int i=a;i<=c;i++){
		for(int j=b;j<=d;j++){
			if(i==a&&j==b)	dp[i][j]=1;
			else if(i==a)	dp[i][j]=dp[i][j-1]*i%MOD;
			else if(j==b)	dp[i][j]=dp[i-1][j]*j%MOD;
			else{
				dp[i][j]=(dp[i][j-1]*i%MOD+dp[i-1][j]*j%MOD-dp[i-1][j-1]*(i-1)%MOD*(j-1)%MOD+MOD)%MOD;
			}
		}
	}
	printf("%lld\n",dp[c][d]);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 73140
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct Node* NodePointer;

typedef struct Node {
  int key;
  NodePointer next, pre;
} Node;

NodePointer head, last;

NodePointer make_node(int key) {
  NodePointer tmp = malloc(sizeof(Node));
  tmp->next = tmp->pre = NULL;
  tmp->key = key;
  return tmp;
}

void init() {
  head = malloc(sizeof(Node));
  last = malloc(sizeof(Node));
  head->next = last;
  last->pre = head;
}

void insert(NodePointer s, int key) {
  NodePointer node = make_node(key);
  NodePointer t = s->next;
  s->next = node;
  node->pre = s;
  node->next = t;
  t->pre = node;
}

void delete(NodePointer p) {
  NodePointer s = p->pre;
  NodePointer t = p->next;
  s->next = t;
  t->pre = s;
  free(p);
}

int main() {
  int N, num;
  char str[30];
  NodePointer p;
  init();
  scanf(" %d ", &N);
  while(N--) {
    scanf(" %s ", str);
    if(!strcmp(str,"insert")) {
      scanf(" %d ", &num);
      insert(head,num);
    } else if(!strcmp(str,"delete")) {
      scanf(" %d ", &num);
      for(p = head->next; p != last; p = p->next) {
        if(p->key == num) {
          delete(p);
          break;
        }
      }
    } else if(!strcmp(str,"deleteFirst")) {
      delete(head->next);
    } else if(!strcmp(str,"deleteLast")) {
      delete(last->pre);
    }
  }

  for(p = head->next; p != last; p = p->next) {
    printf(p == head->next? "%d":" %d", p->key);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 33040
#include<bits/stdc++.h>
using namespace std;
int main() {
    double a,b;
    cin >> a >> b;
    int d = int(a/b);
    int r = int(a)%int(b);
    double f = a/b;
    printf("%d %d %.8f\n",d,r,f);
    return 0;
}


Measured memory_bytes: 3212
import sys

def solve():
    input = sys.stdin.readline
    H, W, A, B = map(int, input().split())
    S = [[None] * W for _ in range(H)]
    for h in range(B):
        for w in range(A): S[h][w] = 0
        for w in range(A, W): S[h][w] = 1
    for h in range(B, H):
        for w in range(A): S[h][w] = 1
        for w in range(A, W): S[h][w] = 0
    for h in range(H):
        print("".join(map(str, S[h])))

    return 0

if __name__ == "__main__":
    solve()

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;
typedef pair<double, double> PDD;

const int MAX_N = 1e6+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll inv(ll base) {
    return modExp(base, MOD-2);
}

ll mul(ll A, ll B) {
    return (A*B)%MOD;
}

ll add(ll A, ll B) {
    return (A+B)%MOD;
}

ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}

ll* facs = new ll[MAX_N];
ll* facInvs = new ll[MAX_N];

ll choose(ll a, ll b) {
    if (b > a) return 0;
    if (a < 0) return 0;
    if (b < 0) return 0;
    ll cur = facs[a];
    cur = mul(cur, facInvs[b]);
    cur = mul(cur, facInvs[a-b]);
    return cur;
}

void initFacs() {
    facs[0] = 1;
    facInvs[0] = 1;
    for (int i=1; i<MAX_N; i++) {
        facs[i] = (facs[i-1] * i) % MOD;
        facInvs[i] = inv(facs[i]);
    }
}

void solve() {

}

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

    ll x, y;
    cin >> x >> y;

    if ((x+y)%3 != 0) {
        cout << 0;
        return 0;
    }

    ll k = (x+y) / 3;
    if (x-k < 0 || 2*k-x < 0) {
        cout << 0;
        return 0;
    }

    ll n = (2*x - y) / 3;

    initFacs();
    ll ans = choose(k, n);

    cout << ans;

    return 0;
}


Measured memory_bytes: 15872
import sys
import numpy as np

#n=int(sys.stdin.readline())
n,m=map(int,sys.stdin.readline().split())
h=np.array(sys.stdin.readline().split(),dtype='int64')

l=[1]*n

for _ in range(m):
    a,b=map(int,sys.stdin.readline().split())
    if h[a-1]<h[b-1]:
        l[a-1]=0
    elif h[b-1]<h[a-1]:
        l[b-1]=0
    else:
        l[a-1]=0
        l[b-1]=0
cnt=0
for i in range(n):
    if l[i]==1:
        cnt+=1
print(cnt)
    


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 59, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    int n, m;   cin >> n >> m;

    ll x = 0;
    for(int i = 0;i < n;i++){
        ll a;  cin >> a;
        x += a * (n - i - 1) - a * i;
        x %= modulo;
    }

    ll y = 0;
    for(int i = 0;i < m;i++){
        ll a;  cin >> a;
        y += a * (m - i - 1) - a * i;
        y %= modulo;
    }

    cout << (x * y) % modulo;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int i,x,y;
   char s[100000];

   scanf("%s",s);

   x=0; y=0; 
   for(i=0;s[i]=='1'||s[i]=='0';i++){
      if(s[i]=='0'){
        x=x+1;
      }
      else if(s[i]=='1'){
        y=y+1;
      }
   }

   if(x>y) printf("%d\n",y*2);
   else    printf("%d\n",x*2);

   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			char[] chars = data.toCharArray();

			int total = 0;
			for (int i = 0; i < chars.length; i++) {
				int n = Integer.parseInt(String.valueOf(chars[i]));
				total += n;
			}

			System.out.println(total % 9 == 0 ? "Yes" : "No");
		}
	}
}

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

int main(){
    int s;
    cin >> s;
    int a[1000001];
    a[0] = s;
    int num[1000001];
    for(int i=0;i<1000001;++i){
        num[i] = 0;
    }
    num[a[0]]++;
    for(int i=1;i<1000001;++i){
        if(a[i-1] % 2 == 0){
            a[i] = a[i-1]/2;
        }else{
            a[i] = 3*a[i-1] + 1;
        }
        num[a[i]]++;
        if(num[a[i]]==2){
            cout << i+1 << endl;
            break;
        }
    }
    return 0;
}


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

int main (void){
  long long int n = 0,m = 0;
  cin >> n >> m;
  vector<vector<long int>> g(n,vector<long int>());
  vector<int> yet(n,0);
  vector<pair<int,int>> ans(n,{0,0});
  for(int i = 0;i < m;i++){
    long int l = 0,f = 0;
    cin >> l >> f;
    l--;
    f--;
    g[l].push_back(f);
    g[f].push_back(l);
  }
  queue<pair<long int,int>> q;
  pair<long int,int> a,b;
  long int cur;
  q.push({0,0});
  yet[0]++;

  while(!q.empty()){
    a = q.front();
    q.pop();
    cur = a.first;
    a.second++;
    for(int i = 0;i < g[cur].size();i++){
      if(yet[g[cur][i]] == 0){
        yet[g[cur][i]]++;
        q.push({g[cur][i],a.second});
        ans[g[cur][i]].first = a.second;
        ans[g[cur][i]].second = cur + 1;
      }
    }
  }

  for(int i = 1;i < n;i++){
    if(ans[i].first == 0){
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  for(int i = 1;i < n;i++){
    cout << ans[i].second <<endl;
  }

  return 0;
}

Measured memory_bytes: 14024
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
tmp = 1000
for i, h in enumerate(H):
    k = abs(A - (T - h * 0.006))
    if k < tmp:
        tmp = k
        ans = i

print(ans + 1)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
	int A,B,C,D,ans=0;

	scanf("%d",&A);
	scanf("%d",&B);

	if(A<B){
		ans=ans+A;
	}else{
		ans=ans+B;
	}
	
	scanf("%d",&C);
	scanf("%d",&D);

	if(C<D){
		ans=ans+C;
	}else{
		ans=ans+D;
	}
	
	printf("%d",ans);

	return 0;
}

	
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
#define INF ((int)1e9)
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int c[3][3];

bool solve(int a1){
    int a[3];
    int b[3];
    a[0] = a1;
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    rep(i,3){
        rep(j,3){
            int tmp_c = a[i] + b[j];
            if(tmp_c!=c[i][j]){
                return false;
            }
        }
    }
    return true;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
rep(i,3){
    rep(j, 3) cin >> c[i][j];
}
reps(a1,1000,-1000){
    if(solve(a1)){
        cout << "Yes" << endl;
//        system("pause");
        return 0;
    }
}
cout << "No" << endl;
// system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
char rAnimal(char flag, char cAnimal, char lAnimal)
{
    if(flag=='o')
    {
        if(cAnimal=='S')
            return lAnimal;
        else
        {
            if(lAnimal=='S')
                return 'W';
            else
                return 'S';
        }
    }
    else
    {
        if(cAnimal=='W')
            return lAnimal;
        else
        {
            if(lAnimal=='S')
                return 'W';
            else
                return 'S';
        }
    }
}
int main(int argc, const char * argv[])
{
    string t[4]={"SS","SW","WS","WW"},s,ans;
    int n;
    cin>>n>>s;
    bool found=false;
    for(int k=0;k<4;k++)
    {
        found=true;
        ans=t[k];
        for(int i=2;i<n;i++)
        {
            char next=rAnimal(s[i-1], ans[i-1], ans[i-2]);
            ans.push_back(next);
        }
        
        if(ans[0]!=rAnimal(s[n-1], ans[n-1], ans[n-2]))
        {
            found=false;
            continue;
        }
        if(ans[1]!=rAnimal(s[0], ans[0], ans[n-1]))
        {
            found=false;
            continue;
        }
        if(found)
            break;
    }
    if(found)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(a);CIN(b);
    bool zero=false;
    long ne =0;
    for(;a <= b;a++){
        if(a<0)ne++;
        if(a==0)zero=true;
        if(a>0)break;
    }
    if(zero){
        COUT("Zero");
        rt 0;
    }
    if(ne%2==0){
        COUT("Positive");
        rt 0;
    }
    if(ne%2==1){
        COUT("Negative");
        rt 0;
    }
    rt 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main(){
    string S; cin >> S;
    int ans = INFI;
    for(int i=0;i<S.size()-2;i++){
        int n = atoi(S.substr(i,3).c_str());
        if(abs(753-n) < ans) ans = abs(753-n);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
k, a, b = map(int, input().split())

if(a>=b-1):
    print(1+k)
else:
    if(k<=a):
        print(1+k)
    else:
        if((k-a+1)%2==0):
            print(((k - a + 1) // 2) * (b-a) + a)
        else:
            print(((k - a + 1) // 2) * (b - a) + a + 1)

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

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

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

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

int main(){
    int n;
    cin >> n;
    ll a[100010][3];
    ll dp[100010][3];
    rep(i,n) rep(j,3) cin >> a[i+1][j];
    rep(i,3) dp[0][i] = 0;
    for(int i = 1; i < n+1; i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + a[i][1];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + a[i][2];
    }
    ll res=0;
    cout << max(max(dp[n][0],dp[n][1]),dp[n][2]) << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <algorithm>
using namespace std;
int N,ptr=0,res;
int A [100000];
int main ()
{
scanf ("%d",&N);
for (int i=0;i<N;i++)scanf("%d",&A[i]);
sort(A,A+N);
while(ptr<N){
int cc =A[ptr],f=0;
while(ptr<N&&A[ptr]==cc)f++,ptr++;
res+=f%2;
}
printf( "%d\n" ,res );
}

Measured memory_bytes: 512
n, k = map(int,input().split())
a = list(map(int,input().split()))
from collections import deque

ans = deque()
ans.appendleft(1)
count = 1
s = -1
zeros = [0]*n

while True:
    if zeros[a[count-1]-1] == 1:
        s = a[count-1]
        break
    else:
        ans.append(a[count-1])
        zeros[count-1]=1
        count = a[count-1]

ans = list(ans)
if s == -1:
    print(ans[k])
else:
    t = ans.index(s)
    if t >= k:
        print(ans[k])
    else:
        ans = ans[t:]
        print(ans[(k-t)%len(ans)])


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0;(i) < (ll)(n);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1;(i) >= 0LL;(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, P;
    ll oe[2] = {};
    cin >> N >> P;
    rep(i, N) {
        ll temp;
        cin >> temp;
        oe[temp % 2]++;
    }
    if(oe[1] == 0) {
        if(P) cout << 0 << endl;
        else cout << (1LL << N) << endl;
    } else {
        cout << (1LL << (N - 1)) << endl;
    }
    return 0;
}


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

using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int co = (a & 1) + (b & 1) + (c & 1);
    int an = 0;
    if(co == 1){
        if(a&1){
            b++, c++;
        }
        else if(b&1){
            a++, c++;
        }
        else if(c&1){
            a++, b++;
        }
        an++;
    }
    else if(co == 2){
        if(a%2==0){
            b++, c++;
        }
        else if(b%2==0){
            a++, c++;
        }
        else if(c%2==0){
            a++, b++;
        }
        an++;
    }
    int mx = max(a, max(b, c));
    while(a < mx){
        a += 2;
        an++;
    }
    while(b < mx){
        b += 2;
        an++;
    }
    while(c < mx){
        c += 2;
        an++;
    }
    cout << an << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int a;
string s;

signed main(){
  cin >> a >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    n%=10;
    if(n==3){
        cout << "bon" << endl;
    }
    else if(n==0||n==1||n==6||n==8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

void selectionSort(int A[], int N){
  int i, minj, j, t, c = 0;
  for(i = 0; i < N; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    if(i != minj){
      t = A[i];
      A[i] = A[minj];
      A[minj] = t;
      c++;
    }
  }
  for(i = 0; i < N; i++){
    printf("%d",A[i]);
    if(i <= N-2) printf(" ");
  }
  printf("\n%d\n", c);
}


int main(void){
  int i, n;
  scanf("%d", &n);
  int *a;
  a = malloc(n * sizeof(int));
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  selectionSort(a, n);
  return 0;
}

Measured memory_bytes: 1816
#include <stdio.h>
#include <string.h>
#define ll long long
#define MAX 3001

ll dp[MAX][MAX];
ll table[MAX][MAX];

ll max(ll a, ll b)
{
	if (a > b)
		return a;
	else
		return b;
}

ll mats(ll i, ll j)
{
	if (i < 0 || j < 0)
		return 0;
	if (dp[i][j] == -1)
	{
		if (table[i][j] == 0)
			dp[i][j] = max(mats(i - 1, j), mats(i, j - 1));
		else
			dp[i][j] = mats(i - 1, j - 1) + 1;
	}
	return dp[i][j];
}

int main(void)
{
		for(int i = 0; i < MAX; i++)
			for(int j = 0; j < MAX; j++)
				dp[i][j] = -1, table[i][j] = 0;

		char str1[MAX], str2[MAX];
		scanf("%s %s", str1, str2);
		ll len1 = strlen(str1);
		ll len2 = strlen(str2);

		for (int i = 0; i < len1; i++)
			for (int j = 0; j < len2; j++)
				if (str1[i] == str2[j])
					table[i][j] = 1;
		ll max = mats(len1 - 1, len2 - 1);
		ll counter = max;
		char str[max + 1];
		str[max] = '\0';
		//if (max != 0)
		//{
			ll i = len2 - 1, j = len1 - 1;
			while(j != -1)
			{
				ll ii = i;
				for (int k = i; k >= 0; k--)
				{
					if (dp[j][k] == counter && table[j][k] == 1)
					{
						str[counter - 1] = str1[j];
						i = k - 1, counter--;
						break;
					}
				}
				j--;
			}

			printf("%s\n", str);
		//}
		//else
		//	printf("\n");
}


Measured memory_bytes: 141184
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#define MOD 1000000007LL
using namespace std;

int main(){
	string a, b;
	cin >> a >> b;
	if(a.size() < b.size()) cout << "LESS" << endl;
	else if (a.size() > b.size()) cout << "GREATER" << endl;
	else{
		if(a.compare(b) > 0) cout << "GREATER" << endl;
		else if(a == b) cout << "EQUAL" << endl;
		else cout << "LESS" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<queue>
#include<cstddef>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
usize n,m;
cin >> n >> m;
priority_queue<i64,vector<i64>> que;
rep(i,n){
    i64 a;
    cin >> a;
    que.push(a);
}
while(m){
    m--;
    i64 k = que.top();
    que.pop();
    k /= 2;
    que.push(k);
}
i64 sum = 0;
rep(i,n){
    i64 k = que.top();
    que.pop();
    sum += k;
}
cout << sum << endl;
}

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

#define rep(i, n)     for (int i = 0; i < n; ++i)
#define rep1(i, n)    for (int i = 1; i < n + 1; ++i)
#define repN(i, m, n) for (int i = m; i < n; ++i)
#define repR(i, n)    for (int i = n - 1; i >= 0; --i)

using namespace std;

int main() {
	string s;
	long long sum = 0;
	cin >> s;

	rep(i, s.length()) {
		sum += s[i] - '0';
	}

	if (sum % 9 == 0) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

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

    string str("1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51");
    char retsu[] = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";

    int conmma_count = 0;
    char num[3] = "";
    int num_start = 0;
    int num_end = 0;
    for (int i = 0; i < strlen(retsu); ++i){
        if (retsu[i] == ',') {
            conmma_count++;
            num_end = i;
            // cout << num_start << " " << num_end << endl;
            if (conmma_count == k) {
                strncpy(num, &retsu[num_start], num_end - num_start);
                cout << num << endl;
                return 0;
            }
            num_start = i + 2;
        }
    }
    cout << 51 << endl;
    return 0;
}



Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n = I()

P = FLI()

min = 10**9
ans = 0
for i in range(n):
    if P[i] < min:
        ans += 1
        min = P[i]
        
print(ans)

Measured memory_bytes: 36120
import sys
bbn=1000000007
	
#+++++

		
def main():
	n,m = map(int, input().split())
	ac_list=[False]*n
	wa_list=[0]*n
	for i in range(m):
		a,b=input().split()
		a=int(a)-1
		if not ac_list[a] and b=='WA':
			wa_list[a]+=1
		elif b =='AC':
			ac_list[a]=True
	ra=sum(ac_list)
	rb=sum([c if t else 0 for c,t in zip(wa_list,ac_list)])
	print(ra,rb)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

std::vector<ll> divisor(ll n){
  std::vector<ll> div;
  for(ll p=1;p*p<=n;++p){
    if(n%p==0){
     div.push_back(p);
     if(p*p!=n)div.push_back(n/p);
    }
  }
  std::sort(div.begin(),div.end());
  return div;
}

signed main(){

  ll n;
  cin>>n;
  vector<ll> ans(n+1);
  vector<int> prime(n+1,1);

  for(ll i=1;i<=n;++i){
    //if(prime[i])ans[i]++;
    ans[i]++;
    for(ll j=i+i;j<=n;j+=i){ans[j]++;}
  }

  ll res = 0;
  rep(i,n+1)res+=(i*ans[i]);
  cout<<(res)<<endl;

}

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

int N,M;
int v[3000],h[3000];
int t[3000],s[3000];

int dp[3001][3001][2];

void maxf(int &a,int b){
  a=max(a,b);
}

int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
    cin>>v[i]>>h[i];
    if(i>0)v[i]+=v[i-1];
  }
  for(int i=0;i<M;i++){
    cin>>t[i]>>s[i];
  }

  for(int i=0;i<3001;i++)
    for(int j=0;j<3001;j++)
      for(int k=0;k<2;k++)
        dp[i][j][k]=-1e9;
  
  dp[0][0][0]=0;
  
  for(int i=0;i<M;i++){
    for(int j=0;j<=N;j++){
      int c0=dp[i][j][0];
      int c1=dp[i][j][1];
      
      //0
      if(j<N&&v[j]<=t[i]){
        maxf(dp[i][j+1][1],c0+h[j]);
      }
      if(s[i]<=c0){
        maxf(dp[i+1][j][0],c0);
      }
      
      //1
      if(j<N&&v[j]<=t[i]){
        maxf(dp[i][j+1][1],c1+h[j]+abs(h[j]-h[j-1]));
      }
      if(s[i]<=dp[i][j][1]){
        maxf(dp[i+1][j][0],c1);
      }
    }
  }

  int ans=-1;
  for(int j=1;j<=N;j++){
    if(dp[M][j][0]>=0){
      ans=t[M-1]-v[j-1];
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 73492
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
map<string, int> items;
map<string, vector<string> > combs;

int rec(string name){
  if (combs.count(name) == 0)
    return items[name];
  int sum = 0;
  for (int i=0;i<combs[name].size();i++){
    sum += rec(combs[name][i]);
  }
  return min(sum, items[name]);
}

int main(){
  int m, n, l, cost;
  string name, tmp;
  while (cin >> n && n){
    items.clear();
    combs.clear();
    for (int i=0;i<n;i++){
      cin >> name;
      cin >> cost;
      items[name] = cost;
    }
    cin >> m;
    for (int i=0;i<m;i++){
      cin >> name >> l;
      for (int j=0;j<l;j++){
        cin >> tmp;
        combs[name].push_back(tmp);
      }
    }
    cin >> name;
    cout << rec(name) << endl;
  }

  return 0;
}

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

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

const long long MOD = 1000000007;

int main(){
  int a,b;
  int ans = -1;
  cin >> a >> b;
  for(int i=1;i<1001;i++){
    if((int)(i*0.08)==a && (int)(i*0.1)==b){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<math.h>
#define Max 1000000
#define INF 1000000000000000000
using namespace std;

int main(){

	string s;
	cin >> s;
	int i=0,j=s.size()-1,c=0;
	while(i<j){
		if(s[i] != s[j])
			c++;
		i++;
		j--;
	}

	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    ll N,M,X; cin>>N>>M>>X;
    vi C(N);
    vii A(N,vi(M));
    rep(i,0,N){
        cin>>C[i];
        rep(j,0,M) cin>>A[i][j];
    }
    ll ans=INF;
    rep(a,0,(1ll<<N)){
        std::bitset<20> bit(a);
        vi memo(M);
        ll sum=0;
        rep(i,0,N){
            if(bit.test(i)){
                sum+=C[i];
                rep(j,0,M) memo[j]+=A[i][j];
            }
        }
        bool flag=1;
        rep(i,0,M){
            if(memo[i]<X) flag=0;
        }
        if(flag){
            ans=std::min(ans,sum);
        }
    }
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
n, m = [int(x) for x in raw_input().split()]

d = [[1000000000] * n for i in range(n)]

edges = []
for i in range(m):
    a, b, c = [int(x) for x in raw_input().split()]
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
    edges.append([a, b, c])

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0
for a, b, c in edges:
    if d[a][b] < c:
        ans += 1

print ans


Measured memory_bytes: 2948
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for i in range(N):
    X,L = [int(x) for x in stdin.readline().rstrip().split()]
    data.append((X+L,X-L))

ans = 0
left = -10**9-1
for k,j in sorted(data):
    if j >= left:
        left = k
        ans += 1
print(ans)

Measured memory_bytes: 17808
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  string s;
  while(cin >> s){
    LLI ans = 0;
    int n = s.size();

    string t;
    REP(i,n-1){
      if(s[i] == 'B' and s[i+1] == 'C'){
	t.push_back('X');
	++i;
      }
      else t.push_back(s[i]);
    }

    LLI c = 0;
    REP(i,(int)t.size()){
      if(t[i] == 'A') ++c;
      else if(t[i] == 'X') ans += c;
      else c = 0;
    }

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


Measured memory_bytes: 916
delta = ((1, 0), (0, 1), (-1, 0), (0, -1))
def ds(here, lb, ub, field):
	if field[here[1]][here[0]] == "#":
		return 0
	result = 1
	field[here[1]][here[0]] = "#"
	for dx, dy in delta:
		next = (here[0]+dx,here[1]+dy)
		if lb[0] <= next[0] < ub[0] and lb[1] <= next[1] < ub[1]:
			result += ds(next, lb, ub, field)
	return result
while 1:
	W, H = map(int,raw_input().split(" "))
	if W == H == 0:
		break
	floor = [list(raw_input()) for i in range(H)]
	start = None
	for i in range(H):
		for j in range(W):
			if floor[i][j] == "@":
				start = (j,i)
				break
		if start is not None:
			break
	print ds(start,(0,0),(W,H),floor)

Measured memory_bytes: 4500
#include<stdio.h>
#include<stdlib.h>

#define MAX 100001
#define NOT -1;

int s[MAX],n;

int binarySearch(int t){
  int l,r,mid;
  l = 0;
  r = n;
  while(l < r){
    mid = (l+r)/2;
    if(s[mid] == t)return 1;
    else if(t < s[mid])r = mid;
    else l = mid +1;
  }
  return NOT;
}

int main(){
  int q,sum=0;
  int t;
  int i,j;
  
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&t);
    j = binarySearch(t);
    if(j != -1)sum++;
  }


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



Measured memory_bytes: 2108
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        a: usize,
        b: Chars,
    }

    let mut b100 = 0;
    for c in b.iter() {
        match c {
            '.' => continue,
            _ => {
                let d = c.to_digit(10).unwrap();
                b100 = b100 * 10 + d;
            }
        }
    }

    let result = a * b100 as usize / 100;

    echo!(result);
}


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

int main() {
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<s.size()-1;i++){
        if(s.at(i)=='A'&&s.at(i+1)=='C') ans++;
    }
    if(ans>=1) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
/*for better*/
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define M 998244353
using namespace std;

int main()
{
    fast; 
    int n,i,j;
    cin>>n;
    ll a[n][3];
    f(i,0,n)
    	f(j,0,3)
    		cin>>a[i][j];
    ll dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];

    f(i,1,n)
    	f(j,0,3)
    		dp[i][j]=a[i][j]+max(dp[i-1][(j-1+3)%3],dp[i-1][(j+1)%3]);

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 4992
#include <stdio.h>
int main(void){
   int n,i,j,k,l;
   int tem=0;
   int dice[24][6];
   int label[24][6]={{1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},{1,5,4,3,2,6},{2,1,4,3,6,5},{2,3,1,6,4,5},
   {2,4,6,1,3,5},{2,6,3,4,1,5},{3,1,2,5,6,4},{3,2,6,1,5,4},{3,5,1,6,2,4},{3,6,5,2,1,4},{4,1,5,2,6,3},
   {4,2,1,6,5,3},{4,5,6,1,2,3},{4,6,2,5,1,3},{5,1,3,4,6,2},{5,3,6,1,4,2},{5,4,1,6,3,2},{5,6,4,3,1,2},
   {6,2,4,3,5,1},{6,3,2,5,4,1},{6,4,5,2,3,1},{6,5,3,4,2,1}};
   
   scanf("%d",&n);
   int dices[n][6];
   
   for(i=0;i<n;i++){
       for(j=0;j<6;j++) scanf("%d",&dices[i][j]);
   }
   
   /*for(i=0;i<n;i++){
       for(j=0;j<6;j++) {
           printf("%d",dices[i][j]);
       }
       putchar('\n');
   }*/
   
   for(i=0;i<n-1;i++){
       for(j=i+1;j<n;j++){
           
           for(k=0;k<24;k++){
               for(l=0;l<6;l++) dice[k][l]=dices[j][label[k][l]-1];
           }
           
          /* for(k=0;k<24;k++){
               for(l=0;l<6;l++) {
                   printf("%d",dice[k][l]);
               }
               putchar('\n');
           }*/
           
           for(k=0;k<24;k++){
               for(l=0;l<6;l++) {
                   if(dice[k][l]==dices[i][l]) {
                       tem+=1;
                   }else{
                       break;
                   }
               }
               if(tem==6){
                    printf("No\n");
                    return 0;
               }else{
                   tem=0;
               }
           }
       }
   }
   
   printf("Yes\n");
   return 0;
}



Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		long long sum = 0, tmp = i + 1;
		while (tmp != 0) {
			sum += tmp % 10;
			tmp /= 10;
		}
		if (sum >= A && sum <= B)ans+=i+1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e6 + 2; int n;
const lli mod = 2;
char a[maxN];

lli fat[maxN];
lli modPow(lli x, lli y)
{
  lli ans = 1;
  while (y)
  {
    if (y & 1LL) ans = ans * x % mod;
    x = x * x % mod, y >>= 1LL;
  }
  return ans;
}
lli inv(lli x)
{
  return modPow(x, mod - 2);
}
lli choose(lli nn, lli k)
{
  if (nn < k) return 0;
  if (nn < mod) return fat[nn] * inv(fat[k] * fat[nn - k] % mod) % mod;
  lli ans = 1;
  while (nn || k)
  {
    lli nnn = nn % mod, kk = k % mod;
    nn /= mod, k /= mod;
    ans = ans * choose(nnn, kk) % mod;
  }
  return ans;
}
/*
1
0
2
0
2
2
2
1
*/
int main()
{
  fat[0] = 1;
  for (lli i = 1; i < maxN; i++)
    fat[i] = i * fat[i - 1] % mod;

  while (scanf("%d", &n) != EOF)
  {
    scanf(" %s", a);
    DEBUG {
      int x[n][n];
      for (int j = 0; j < n; j++)
      {
        printf("%c%c", a[j], j < n - 1 ? ' ' : '\n');
        x[0][j] = a[j] - '0';
      }

      for (int i = 1; i < n; i++)
      {
        for (int j = 0; j < i; j++) printf(" ");
        for (int j = 0; j < n - i; j++)
        {
          x[i][j] = abs(x[i - 1][j] - x[i - 1][j + 1]);
          printf("%d%c", x[i][j], j < n - i - 1 ? ' ' : '\n');
        }
      }
      printf("----------\n");
    }

    int x[n]; for (int i = 0; i < n; i++) x[i] = (a[i] - '1');

    bool hasOne = false;
    lli answer = 0;
    for (int i = 0; i < n; i++)
      if (x[i] == 1)
        answer = (answer + choose(n - 1, i)) % mod, hasOne = true;

    if (hasOne)
      printf("%lld\n", answer & 1LL);
    else
    {
      answer = 0;
      for (int i = 0; i < n; i++)
        if (x[i] == 2)
          answer = (answer + choose(n - 1, i)) % mod;
      printf("%lld\n", 2LL * (answer & 1LL));
    }
  }
  return 0;
}

Measured memory_bytes: 12928