akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
#define FORk(N) for(int k=0;k<N;++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A(M),memo(N,-1);
  vector<bool> k(N,true);
  FORi(M){
    cin>>A[i];
    k[A[i]]=false;
  }
  function<ll(ll)> f=[&](ll i)->ll {
    if(i==N)return 1;
    if(k[i]==false)return 0;
    if(memo[i]!=-1)return memo[i];
    ll num=0;
    num += f(i+1);
    num += f(i+2);
    num%=1000000007;
    memo[i]=num;
    return num;
  };
  cout<<f(0)<<endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

//For DP
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;
}

//Union-Find tree
struct UnionFind{
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N;  i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る : root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { //xとyの木を併合
        int rx = root(x); //xの木の根をrx
        int ry = root(y); //yの木の根をyx
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)ときはそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時 : xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int main(){
    int n,k;
    cin >> n >> k;
    ll d[k];
    rep(i,k) cin >> d[i];
    set<int> love = {0,1,2,3,4,5,6,7,8,9};
    rep(i,k) love.erase(d[i]);
    queue<int> que; 
    for(auto itr=love.begin();itr!=love.end();itr++){
        if(*itr != 0) que.push(*itr);
    }
    int nq;
    while(!que.empty()){
        nq = que.front();
        que.pop();
        if (nq >= n) break;
        for(auto itr=love.begin();itr!=love.end();itr++){
            que.push(nq*10+*itr);
        }
    }
    cout << nq << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}



int main(void) {

	int t = 0, sum = 0;

	string s;
	cin >> s;
	for (char c : s) {
		if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
			t++;
		}
		else {
			CHMAX(sum,t);
			t = 0;
		}
	}
	CHMAX(sum, t);

	COUT(sum);

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main
{
    static class Plate
    {
        Plate(long a, long b) { this.a = a; this.b = b; }
        final long a, b;
    }

    public static void main(String[] args)
    {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        Plate[] p = new Plate[n];
        for (int i = 0; i < n; i++) {
            long a = cin.nextLong();
            long b = cin.nextLong();
            p[i] = new Plate(a, b);
        }
        Arrays.sort(p, (x, y) -> Long.compare(y.a + y.b, x.a + x.b));
        long sign = 1;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += sign * p[i].a - (1 - sign) * p[i].b;
            sign = 1 - sign;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 95964
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cstdio>
#include<cfloat>

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double norm(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}

int main(void){
  double D;
  point p,v;
 
  while(cin >> D,D){
  
    cin >> p.x >> p.y >> v.x >> v.y;
     
    double d=D+1;
    double a=dot(p,v)/norm(p)/norm(v);

    if(abs(1.0 + a) < EPS )d=norm(p);
    else if(abs(1.0 - a) < EPS)d=2.0-norm(p);

    if(d<D || abs(d-D)<EPS)printf("%.8f\n",d);
    else cout << "impossible" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vector<int> vec[MAX_N];

void solve() {
	cin >> N;
	int M = -1;
	for(int m = 1; m <= 1000; m++) {
		if(N == m * (m - 1) / 2) {
			M = m;
			break;
		}
	}
	if(M == -1) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
		cout << M << "\n";
		int cnt = 1;
		rep(i, 0, M) {
			rep(j, i + 1, M) {
				vec[i].pb(cnt);
				vec[j].pb(cnt);
				cnt++;
			}
		}
		rep(i, 0, M) {
			cout << sz(vec[i]) << " ";
			rep(j, 0, sz(vec[i])) {
				cout << vec[i][j] << " ";
			}
			cout << "\n";
		}
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl;
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if(a==1){
    if(b==1) co(1000000);
    if(b==2) co(500000);
    if(b==3) co(400000);
    if(b>=4) co(300000);
  }
  if(a==2){
    if(b==1) co(500000);
    if(b==2) co(400000);
    if(b==3) co(300000);
    if(b>=4) co(200000);
  }
  if(a==3){
    if(b==1) co(400000);
    if(b==2) co(300000);
    if(b==3) co(200000);
    if(b>=4) co(100000);
  }
  if(a>=4){
    if(b==1) co(300000);
    if(b==2) co(200000);
    if(b==3) co(100000);
    if(b>=4) co(0);
  }
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	char botton[10] = {'w','\0','k','s','t','n','h','m','y','r'};
	char ch;

	while((ch = getchar()) != '\n'){
		switch(ch){


		case '1':
			ch = getchar();
			if(ch == 'T'){
				printf("a");
			}else if(ch == 'L'){
				printf("i");
			}else if(ch == 'U'){
				printf("u");
			}else if(ch == 'R'){
				printf("e");
			}else if(ch == 'D'){
				printf("o");
			}
			break;

		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			printf("%c",botton[ch - '0']);
			ch = getchar();
			if(ch == 'T'){
				printf("a");
			}else if(ch == 'L'){
				printf("i");
			}else if(ch == 'U'){
				printf("u");
			}else if(ch == 'R'){
				printf("e");
			}else if(ch == 'D'){
				printf("o");
			}
			break;
		case '0':
			ch = getchar();
			if(ch == 'T'){
				printf("wa");
			}else if(ch == 'U'){
				printf("nn");
			}else if(ch == 'D'){
				printf("wo");
			}
			break;
	
		}
	}
	printf("%c",ch);
	return 0;
}

Measured memory_bytes: 920
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[2][200];
char in[3];
int main(){
	int a;scanf("%d",&a);
	int dir=0;
	for(int i=0;i<a;i++){
		if(dir==0){
			str[0][i+1]=str[1][i+1]=0;
			bool ok=false;
			for(int j=0;j<4;j++){
				for(int k=0;k<2;k++){
					if(j&(1<<k))str[k][i]='#';
					else str[k][i]='.';
				}
				printf("%s\n",str[0]);
				printf("%s\n",str[1]);
				fflush(stdout);
				scanf("%s",in);
				if(in[0]=='T'){
					ok=true;
					break;
				}
			}
			if(!ok)dir=1;
		}

		if(dir){
			for(int j=i-1;j>=0;j--){
				str[0][j+1]=str[0][j];
				str[1][j+1]=str[1][j];
			}
			str[0][i+1]=str[1][i+1]=0;
			for(int j=0;j<4;j++){
				for(int k=0;k<2;k++){
					if(j&(1<<k))str[k][0]='#';
					else str[k][0]='.';
				}
				printf("%s\n",str[0]);
				printf("%s\n",str[1]);
				fflush(stdout);
				scanf("%s",in);
				if(in[0]=='T'){
				//	ok=true;
					break;
				}
			}
		}
	}
	printf("%s\n%s\n",str[0],str[1]);

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
char del=' ';

int main() {
    // メインプログラムここから
    double r1,r2,r;
    cin >> r1 >> r2 ;
    cout << fixed << setprecision(10);
    cout << 1/(1/r1 + 1/r2) << endl;
    // ここまで
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define Min(a,b) (((a) < (b))?(a):(b))
#define Max(a,b) (((a) > (b))?(a):(b))
#define Abs(a) (((a) > 0)?(a):(-1)*(a))
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define SIZE 0

int main() {
   ll n, a, b, c, d, sum = 0;
   cin >> n >> a >> b >> c >> d;
   sum = n - 1;
   for (ll i = sum ; i >= 0 ; --i) {
      if ((b + i * c - (sum - i) * d <= a) && (a <= b + i * d - (sum - i) * c)) { 
         cout << "YES" << endl;  
         return 0;
      }
   }
   cout << "NO" << endl;

   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,x,y,z,h;
	scanf("%d %d",&a,&b);
	if(-100<=a && b <=100)
	{
		x = a+b;
		y = a-b;
		z = a*b;
		h = x;
		if(y >= h)
		{
			h = y;
			if(z >= h)
			{
				h = z;
			}
		}
		else if(z >= h)
			{
				h = z;
			}
	}
	printf("%d\n",h);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define  vi vector<int>
#define pb push_back
//#define int long long
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define pi pair<int,int>
#define F first
#define S second
using namespace std;

//int mod=(int)(1e9+7);

void solve()
{
 
 int n;cin>>n;
 set<string>s;
 for(int i=0;i<n;i++)
  {   string t;
      cin>>t;
      s.insert(t);
  }

  cout<<s.size();
}

signed main()
{ boost;
 //cout<<fixed<<setprecision(14 );
 // int t;cin>>t;
  //for(int i=1;i<=t;i++)
  solve();
 // cout<<"Case #"<<i<<": "<<solve()<<endl;

return 0;
}

Measured memory_bytes: 19248
#include <stdio.h>

  long biscuits = 1;
  long money = 0;
  long K;
  long A;
  long B;
int main()
{
  
  scanf("%ld%ld%ld", &K, &A ,&B);
  
  for (int i = 0; i < K; i++) {
			if (i == K - 1 && money == 0) {
				knock();
			} else if (B > A + 1) {
				if (money == 1) {
					moneyToBiscuit();
				} else if (biscuits >= A) {
					biscuitToMoney();
				} else {
					knock();
				}
			} else {
				knock();
			}
		}

	printf("%ld", biscuits);
	}

	void knock() {
		biscuits++;
	}

	void biscuitToMoney() {
		biscuits -= A;
		money++;
	}

	void moneyToBiscuit() {
		money--;
		biscuits += B;
	}

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

typedef long long ll;
typedef vector<long long> vecll;
typedef vector<string> vecstr;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)
#define len(x) x.size()
#define Sort(x) sort(x.begin(), x.end())
#define rSort(x) sort(x.begin(), x.end(), greater<ll>())

const ll mod_const = 1000000007;

ll modpow(ll a, ll n, ll m) {
    ll result = 1;
    while(n > 0) {
        if(n&1) {
            result = result * a % m;
        }

    a = a * a % m;
    n >>= 1;
    }

    return result;
}

ll modinv(ll a, ll n) {
    if(a <= 1) {
        return 1;
    } else {
        return  n - modinv(n%a, n) * (n/a) % n;
    }
}

ll comb(ll n, ll r, ll m = mod_const) {
    vecll fac = {1, 1};
    vecll inv ={1, 1};
    vecll facinv = {1 , 1};

    rep(i, 2, n) {
        fac.push_back(fac[i-1] * i % m);
        inv.push_back(modinv(i, m));
        facinv.push_back(facinv[i-1] * inv[i] % m);
    }

    if (n<r || n<0 || r<0) {
        return 0;
    } else {
        return fac[n] * (facinv[r] * facinv[n-r] % m) % m;
    }
}
void solve() {
    ll x;
    cin >> x;

    ll money = 100;
    ll cnt = 0;

    while(money < x) {
        cnt++;
        money *= 1.01;
    }

    cout << cnt << endl;

}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int costs[10001];

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

  int n,t,k,case_num = 0;
  while(cin >> n >> t >> k, n){
    case_num++;

    memset(costs,0,sizeof(costs));
    vector< vector<pii> > tree(n);

    for(int i=0;i<n-1;i++){
      int a,b,c;
      cin >> a >> b >> c;
      a--; b--;
      tree[a].push_back(pii(c,b));
      tree[b].push_back(pii(c,a));
      costs[c]++;
    }

    vector<int> base(t), use(n,0);
    for(int i=0;i<t;i++){
      cin >> base[i];
      base[i]--;
      use[base[i]] = 1;
    }

    priority_queue<pii> q;
    for(int v : base){
      for(pii u : tree[v]){
	if(!use[u.second])q.push(u);
      }
    }

    while(q.size()){
      pii p = q.top(); q.pop();
      if(use[p.second])continue;
      use[p.second] = 1;
      costs[p.first]--;

      for(pii u : tree[p.second]){
	if(!use[u.second])q.push(u);
      }
    }

    int p = 0;
    long long res = 0;
    while(k){
      while(k && costs[p]){
	costs[p]--; k--;
	res += p;
      }
      p++;
    }
    cout << "Case " << case_num << ": " << res << endl;
  }
}

Measured memory_bytes: 1904
postorder_elements = []

def post_from_pre_in(preorder_elements, inorder_elements):
    if preorder_elements:
        root = preorder_elements[0]
        root_index = inorder_elements.index(root)
        preorder_left = preorder_elements[1:root_index+1]
        inorder_left = inorder_elements[:root_index]
        preorder_right = preorder_elements[root_index+1:]
        inorder_right = inorder_elements[root_index+1:]
        post_from_pre_in(preorder_left, inorder_left)
        post_from_pre_in(preorder_right, inorder_right)
        postorder_elements.append(root)



n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

post_from_pre_in(a, b)

print(*postorder_elements)

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

int main() {
  string n;
  cin >> n;
  if((n[0] == n[1]) && (n[1] == n[2])) cout << "Yes" << endl;
  else if((n[1] == n[2]) && (n[2] == n[3])) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            int n = int.Parse(szLine);


            // 高速化のためtable作成
            int[] table = new int[] { 1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049 };


            int[] dp = new int[n+1];
            for( int i=1;i<dp.Length;++i)
            {
                int minCount = int.MaxValue;
                for(int j=0;j<table.Length;++j)
                {
                    int idx = i - table[j];
                    if( idx < 0 || dp.Length <= idx) { break; }
                    int tmpCount = dp[idx] + 1;
                    if( tmpCount < minCount)
                    {
                        minCount = tmpCount;
                    }
                }
                dp[i] = minCount;
            }

            Console.WriteLine(dp[n]);
        }
    }
}


Measured memory_bytes: 13216
// AtCoder ABC133: C - Remainder Minimization 2019
// 2019.9.2 bal4u

#include <stdio.h>

int a[4050];
int main()
{
	int i, j, t, L, R, ans;
	
	scanf("%d%d", &L, &R);
	if (R - L >= 4040) { puts("0"); return 0; }
	j = 0; for (i = L; i <= R; i++) a[j++] = i % 2019;
	ans = 2019, R = j;
	for (i = 0; i < R; i++) for (j = i+1; j < R; j++) {
		t = a[i]*a[j] % 2019;
		if (t < ans) ans = t;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    for _ in range(int(input())):
        x,y = map(int,input().split())
        g[i][x-1] = y

ans = 0
for s in range(2**n):
    ok = True
    for i in range(n):
        if (s>>i&1) == 1:
            for j in range(n):
                if g[i][j] == -1:continue
                if (s>>j&1) != g[i][j]:ok = False
    if ok:
        t = str(bin(s)).count("1")
        ans = max(ans,t)
print(ans)

Measured memory_bytes: 3064
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		HashSet<Integer> A = new HashSet<>();
		
		// 結果の出力
		for (int i = 0; i < N; i++) {
			if (!A.add(sc.nextInt())) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
		
		sc.close();
	}
}


Measured memory_bytes: 62012
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000

ll p(ll a){
    if(a%4==0) return a;
    else if(a%4==1) return 1LL;
    else if(a%4==2) return a+1;
    else return 0;
}
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    if(a==0) cout<<p(b)<<endl;
    else cout<<(p(a-1)^(p(b)))<<endl;
}

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

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

int main(){
	int n,m, cost;

	while( cin >> n >> m , n|m ){
		int sum = 0;
		vector<int> vc;
		for(int i=0 ; i<n ; ++i){
			cin >> cost;
			vc.push_back( cost );
		}
		sort( vc.begin() , vc.end() );
		reverse( vc.begin() , vc.end() );
		for(int i=0 ; i<(int)vc.size() ; ++i ){
			if( (i+1)%m != 0 ){
				sum += vc[i];
			}
		}
		cout << sum << endl;
	}
}

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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int sum = accumulate(A.begin(),A.end(), 0);
    int ans = sum*(sum%10 != 0);
    for(int i = 0; i < N; i++) {
        if((sum - A.at(i))%10) {
            ans = max(ans, sum - A.at(i));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
s=input()
t=input()
ans=len(t)
for i in range(len(s)-len(t)+1):
    s1=s[i:i+len(t)]
    sum=len(t)
    for j in range(len(t)):
        if t[j]==s1[j]:sum-=1
    ans=min(ans,sum)
print(ans)

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

N = int(input())
S = [input() for _ in range(N)]
l, m, n = 0, 0, 0
ans = 0
for s in S:
    if s[0] == 'B' and s[-2] == 'A':
        n += 1
    elif s[0] == 'B':
        m += 1
    elif s[-2] == 'A':
        l += 1
    for i in range(len(s)-1):
        if s[i:i+2] == 'AB':
            ans += 1
if n > 0:
    ans += n - 1
    if l > 0:
        l -= 1
        ans += 1
    if m > 0:
        m -= 1
        ans += 1
ans += min(l, m)
print(ans)

Measured memory_bytes: 41072
K = int(input())
s = 7
digit = 1
for i in range(K): # Mod KはK種類しかない
    if s % K == 0:
        break
    digit += 1
    s = int(str(s) + '7') % K #余りで計算してもMod Kの値は変わらない
if s % K == 0:
    print(digit)
else:
    print(-1)


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll a,b,c;cin>>a>>b>>c;
  cout<<c-(min(a,b+c)-b)<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

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

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

    int m = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] != B[i]) m++;
    }

    if (m <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

string divide[4] = {"dream", "dreamer", "erase","eraser"};

int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    for(int i=0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for(int i=0; i < S.size();){
        bool can2 = false;
        for(int j=0; j < 4; ++j){
            string d = divide[j];
            if(S.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2) {
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
a = 3.times.map{gets.split.map(&:to_i)}.flatten
v = []
gets.to_i.times do
  x = gets.to_i
  idx = a.find_index(x)
  v[idx] = true if idx
end

puts [[0,3,6], [1,4,7], [2,5,8], [0,1,2], [3,4,5], [6,7,8], [0,4,8], [2,4,6]].any?{|u| u.all?{|i| v[i]}} ? "Yes" : "No"


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

// 各桁の和を計算する関数
int FindSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() 
{
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = FindSumOfDigits(i); // i の各桁の和
    if (sum >= A && sum <= B) { //  i の各桁の和が A 以上 B 以下かどうか
      total += i;
    }
  }
  cout << total << endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: 014_agc_b / Link: https://agc014.contest.atcoder.jp/tasks/agc014_b?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, M ;

LL ans = 0LL;

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

	cin >> N>>M;
	VI ver(N);
	FOR(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		ver[a]++;
		ver[b]++;
	}

	ans = 1;
	FOR(i, 0, N) {
		if (ver[i] % 2)ans = 0;
	}
	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << "\n";
	}

	return 0;
}


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

int main(){
  string text;
  cin >> text;
  
  if(text == "Sunny" ){
    cout << "Cloudy" << endl;
  }else if(text == "Cloudy" ){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

int MOD;
const int MAXN = 100000;
ll dp[MAXN + 5]; // dp[i] = # of ways to color i's subtree black
ll res[MAXN + 5];

auto mult(auto a, auto b){return (a * b) % MOD;}

void dfs(graph &g, int i, int p = -1) {
  dp[i] = 1;
  trav(e, g[i]) if (e.to != p) {
    dfs(g, e.to, i);
    dp[i] = mult(dp[i], 1 + dp[e.to]);
  }
}

void calc(graph& g, int i, ll above = 1, int p = -1) {
  res[i] = mult(dp[i], above);
  vector<ll> pref_mult, suff_mult;
  rep(k, 0, sz(g[i])) {
    int to = g[i][k].to;
    if (to == p) continue;
    auto contrib = (1 + dp[to]) % MOD;
    pref_mult.PB(!pref_mult.empty() ? mult(pref_mult.back(), contrib) : contrib);
  }
  for (auto k = sz(g[i]) - 1; k >= 0; k--){
    int to = g[i][k].to;
    if (to == p) continue;
    auto contrib = (1 + dp[to]) % MOD;
    suff_mult.PB(!suff_mult.empty() ? mult(suff_mult.back(), contrib) : contrib);
  }
  reverse(all(suff_mult));
  /*
  cout << "At: " << i << " Above: " << above << endl;
  cout << "PRef: " << endl;
  trav(elem, pref_mult) {
    cout << elem << " "; 
  } cout << endl;
  cout << "Suff: " << endl;
  trav(elem, suff_mult)  cout << elem << " ";
  cout << endl;
  */
  int iter = 0;
  trav(e, g[i]) if (e.to != p) {
    auto before = iter ? pref_mult[iter - 1] : 1LL;
    auto after = iter + 1 < sz(suff_mult) ? suff_mult[iter + 1] : 1LL;
    auto exclude_this_subtree = mult(before, after);
    auto nabove = 1 + mult(above, exclude_this_subtree);
    //cout << "Looking at child: " << e.to << " on iter: " << iter << endl;
    //cout << "Before: " << before << " after: " << after << endl;
    calc(g, e.to, nabove, i);
    iter++;
  }
}

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

  int n;
  cin >> n >> MOD;
  graph g(n);
  rep(i, 0, n - 1) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].PB({v});
    g[v].PB({u});
  }
  dfs(g, 0);
  calc(g, 0);
  // rep(i, 0, n) cout << dp[i] << '\n';
  rep(i, 0, n) cout << res[i] << '\n';
}


Measured memory_bytes: 24064
N = int(input())
a = list(map(int, input().split()))

t = [0] * N
for i in range(N - 1, -1, -1):
    t[i] = (sum(t[2 * (i + 1) - 1::i + 1]) % 2) ^ a[i]

print(sum(t))
print(*[i + 1 for i in range(N) if t[i] == 1])


Measured memory_bytes: 13116
#include<iostream>//AtCoder Beginner Contest 126 B YYMMorMMYY
using namespace std;
int main(void)
{
	int s,f,b;
	cin>>s;
	f=s/100;
	b=s-f*100;
	if(f>=1 && f<=12){
		if(b>=1 && b<=12) cout<<"AMBIGUOUS"<<endl;
		else cout<<"MMYY"<<endl;
	}
	else if(f<1 || f>12){
		if(b>=1 && b<=12) cout<<"YYMM"<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

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


int main()
{
	int h, w;

	while (true)
	{
		cin >> h >> w;

		if (h == 0 && w == 0) {
			break;
		}

		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++) {
				cout << "#";
			}

			cout << "\n";
		}

		cout << "\n";
	}

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int N, M;
    cin >> N >>  M;
    vector<int> input(M);
    rep0(i,M){
        cin >> input[i];
    }
    sort(input.begin(),input.end());
    vector<int> diff(M-1);
    for(int i = 0;i<M-1;i++){
        diff[i]=input[i+1]-input[i];
    }
    sort(diff.begin(),diff.end());
    ll res = 0;
    rep0(i,M-N){
        res += diff[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 3944
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int[] c=new int[a];
        int sum=0;
        for(int i=0;i<a;i++){
            c[i]=sc.nextInt();
        }
        for(int i=0;i<=a-2;i++){
            for(int j=i+1;j<=a-1;j++){
                sum+=c[i]*c[j];
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23252
#include<iostream>
#define C std::cout<<
#define F(i,x) for(i=x;i<N;i++)
int main(){
  for(int N;std::cin>>N&&N;){
    int A[N],i,j;
    F(i,0)std::cin>>A[i];
    F(i,0){
      F(j,i+1)if(A[j-1]+1!=A[j])break;
      if(i)C" ";C A[i];
      if(j>i+1){C'-'<<A[j-1];i=j-1;}
    }C '\n';
  }return 0;}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    int cost[n];
    cost[0] = 0;
    cost[1] = abs(arr[1]-arr[0]);
    for(int i=2; i<n; i++)
    {
        cost[i] = min(cost[i-2]+abs(arr[i]-arr[i-2]), cost[i-1]+abs(arr[i]-arr[i-1]));
    }
    cout<<cost[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);


int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> like; // firstを好きと答えた人数

  rep(i, N) {
    int K;
    cin >> K;
    rep(k, K) {
      int A;
      cin >> A;
      like[A-1] += 1;
    }
  }

  int ans = 0;
  rep(i, M) {
    if(like[i]==N) ans++; 
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 100000
int partition(int,int);
int n,A[SIZE];

int main(){
  int i,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  k=partition(0,n-1);
  for(i=0;i<n;i++){
    if(i>0){
      printf(" ");
    }
    if(i==k){
      printf("[");
    }
    printf("%d",A[i]);
    if(i==k){
      printf("]");
    }
  }
  printf("\n");

  return 0;
}

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1; 
}





Measured memory_bytes: 2104
n, k = gets.split.map(&:to_i)
weights = 1.upto(n).map{gets.to_i}
max = weights.max

def count_truck(weights, max_payload, k)
  payload = 0
  truck_counter = 1
  for w in weights do
    next_payload = payload + w
    if next_payload > max_payload
      payload = w
      truck_counter += 1
      break if truck_counter > k
    else
      payload = next_payload
    end
  end
  truck_counter
end

puts (max..1000000000).bsearch{|p| count_truck(weights, p, k) <= k}

Measured memory_bytes: 9736
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define endl '\n'
//#define int long long


signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int n; cin >> n;
        bool ok = true;
        while (n--) {
                int a; cin >> a;
                if (a % 2 == 0) {
                        if (a % 5 && a % 3) ok = false;
                }
        }

        cout << (ok ? "APPROVED" : "DENIED");
        return 0;
}

/*

*/

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


int main() {
  long long n;
  std::cin >> n;
  std::vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  long long min = *std::min_element(a.begin(), a.end());
  long long max = *std::max_element(a.begin(), a.end());
  long long sum = std::accumulate(a.begin(), a.end(), 0LL);
  std::cout << min << " " << max << " " << sum << std::endl;
  return 0;
}



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

using namespace std;

vector< vector<int> > d(101, vector<int>(101, 1000000));

void warshallFloyd(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(void) {
  int n, m;
  cin >> n >> m;

  vector<int> a(m), b(m), c(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
  }
  warshallFloyd(n);

  int ans = 0;
  for (int i = 0; i < m; i++) {
    int v1 = a[i], v2 = b[i];
    bool flag = true;

    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (j == k) continue;
        if (d[j][v1] + c[i] + d[v2][k] == d[j][k]) {
          flag = false;
          break;
        }
      }
    }
    ans += flag;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<vector<int>> gridgraph(int h, int w, vector<string> &s) {
    vector<vector<int>> edge(h * w);
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(i - 1 >= 0 && s[i][j] != s[i - 1][j]) {
                edge[i * w + j].push_back((i - 1) * w + j);
            }
            if(i + 1 < h && s[i][j] != s[i + 1][j]) {
                edge[i * w + j].push_back((i + 1) * w + j);
            }
            if(j + 1 < w && s[i][j] != s[i][j + 1]) {
                edge[i * w + j].push_back(i * w + j + 1);
            }
            if(j - 1 >= 0 && s[i][j] != s[i][j - 1]) {
                edge[i * w + j].push_back(i * w + j - 1);
            }
        }
    }
    return edge;
}
void dfs(int now, vector<int> &visited, vector<vector<int>> &edge, int c) {
    for(auto next : edge[now]) {
        if(visited[next] == -1) {
            visited[next] = c;
            dfs(next, visited, edge, c);
        }
    }
}
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++) {
        cin >> a[i];
    }
    auto edge = gridgraph(h, w, a);
    vector<int> visited(h * w, -1);
    int c = 0;
    for(int i = 0; i < h * w; i++) {
        if(visited[i] == -1) {
            visited[i] = c;
            dfs(i, visited, edge, c);
            c++;
        }
    }
    map<int, ll> white, black;
    for(int i = 0; i < h * w; i++) {
        if(a[i / w][i % w] == '.') {
            white[visited[i]]++;
        } else {
            black[visited[i]]++;
        }
    }
    ll ans = 0;
    for(int k = 0; k < c; k++) {
        ans += black[k] * white[k];
    }
    cout << ans << endl;
}

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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int A,B;
    cin >> A >> B;
    if((A+B)%2==1){
        cout << "IMPOSSIBLE" << endl;
    }else{
        int K = (A+B)/2;
        cout << K << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
    int x,y,d;
    scanf("%d%d",&x,&y);
    
    if(x>=y){
        while(y !=0){
            d=y;
            y=x%y;
            x=d;            
        }
        printf("%d\n",x);
    }
    
    else{
        while(x != 0){
            d=x;
            x=y%x;
            y=d;
        }
        printf("%d\n",y);
    }
    return 0;
}


Measured memory_bytes: 2124
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++) {
        cout << i;

        if (i == x + k - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())

mod = 998244353

def _fac_inv(_n, _mod):
    _fac = [1] * (_n+1)  # 階乗
    _inv = [1] * (_n+1)  # 逆元
    for i in range(_n):
        _fac[i+1] = _fac[i] * (i+1) % _mod
    _inv[n] = pow(_fac[n], mod-2, mod)
    for i in range(_n, 0, -1):
        _inv[i-1] = _inv[i] * i % _mod

    return _fac, _inv

fac, inv = _fac_inv(n, mod)

ans = 0
mm = (m * pow(m-1, n-1-k, mod)) % mod
for ii in range(k+1):
    i = k-ii
    ans = (ans + mm * fac[n-1] * inv[i] * inv[n-1-i]) % mod
    mm = mm * (m-1) % mod

print(ans)


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

typedef long long ll;
const int MAXN = 1e5 + 10;
ll n, a[MAXN], b[MAXN], C;
vector<ll> p, Mat[MAXN];
bool isp[MAXN], se[MAXN];
int cnt[MAXN], sh, shr;

ll getmsk(ll t) {
	for (int i = 0; p[i] * p[i] * p[i] <= t; i++) {
		ll r = p[i] * p[i] * p[i];
		while (t % r == 0)
			t /= r;
	}
	return t;
}
ll rmsk(ll t) {
	ll m = 1;
	for (int i = 0; p[i] * p[i] <= t; i++) {
		if (t % (p[i] * p[i]) == 0)
			m *= p[i], t /= p[i] * p[i];
		else if (t % p[i] == 0)
			m *= p[i] * p[i], t /= p[i];
	}
	if (t != 1)
		m *= t * t;
	return m;
}

void dfs(int v, bool cl) {
	se[v] = 1;
	sh += cnt[v];
	if (cl)
		shr += cnt[v];
	for (int i = 0; i < Mat[v].size(); i++)
		if (!se[Mat[v][i]])
			dfs(Mat[v][i], !cl);
}

int main() {
	for (int i = 2; i < MAXN; i++)
		if (!isp[i]) {
			p.push_back(i);
			for (int j = i; j < MAXN; j += i)
				isp[j] = 1;
		}
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], a[i] = getmsk(a[i]);
	sort(a, a + n);
	for (int i = 0; i < n;) {
		b[C] = a[i];
		while (i < n && a[i] == b[C])
			cnt[C]++, i++;
		C++;
	}
	for (int i = (a[0] == 1); i < C; i++) {
		ll t = rmsk(b[i]);
		int f = lower_bound(b, b + C, t) - b;
		if (f == C || b[f] != t)
			continue;
		Mat[i].push_back(f);
	}
	int ans = 0;
	for (int i = (b[0] == 1); i < C; i++)
		if (!se[i]) {
			sh = shr = 0;
			dfs(i, 0);
			ans += max(shr, sh - shr);
		}
	ans += b[0] == 1;
	cout << ans;
}

Measured memory_bytes: 4992
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))

    timepertry = 1900 * m + 100 * (n - m)

    ans = timepertry * 2 ** m
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
from sys import stdin
input = stdin.readline

n=int(input())
a=list(map(int,input().split()))

cnt=0
sum_r=0
sum_l=sum(a)
sa=[]
for i in range(n):
    sum_r+=a[i]
    sum_l-=a[i]
    sa.append(abs(sum_r-sum_l))
print(min(sa))


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

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> a(n);
  int count = 0;
  int sum = 0;


  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }

  for(int i = 0; i < n; i++){
    if((double)a.at(i)/sum >= (double)1/(4*m)){
      count++;
    }
  }
  
  if(count>=m){
    cout << "Yes" << endl;
	}
  else{
    cout << "No" << endl;
	}
	
}

Measured memory_bytes: 3632