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

class Graph{
	private:
	int V;
	vector<vpll> List;
	public:
	Graph(int v){
		V=v;
		List=vector<vpll>(v);
	}
	void add_edge(int s,int t,ll c){
		List[s].push_back({t,c});
	}
	ll solve(){
		vl d(V,INF);
		d[0]=0;
		ll tmp;
		for(int i=0;i<2*V;i++){
			bool b=1;
			for(int j=0;j<V;j++) for(int k=0;k<List[j].size();k++){
				ll v=List[j][k].first,c=List[j][k].second;
				if(d[j]!=INF&&d[v]>d[j]+c){
					d[v]=d[j]+c;
					b=0;
				}
			}
			if(i==V-1) tmp=d[V-1];
		}
		if(tmp!=d[V-1]) return -INF;
		return -d[V-1];
	}
};

int n,m;

int main(){
	cin>>n>>m;
	Graph g(n);
	for(int i=0;i<m;i++){
		ll s,t,c;
		cin>>s>>t>>c;
		g.add_edge(s-1,t-1,-c);
	}
	ll res=g.solve();
	if(res==-INF) cout<<"inf"<<endl;
	else cout<<res<<endl;
}

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

int main() {
  int N, V[20], C[20],sum = 0;

  cin >> N;
  
  for (int i = 0; i < N; ++i) {
    cin >> V[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> C[i];
    sum += V[i] - C[i] > 0 ? V[i] - C[i] : 0;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  string s; cin >> s;
  map<ll, ll> mp;
  mp[0] = 1;
  reverse(s.begin(), s.end());
  ll now = 0, ten = 1;
  int n = s.size();

  rep(i, n) {
    now = (now + (s[i] - '0') * ten) % 2019;
    ten *= 10;
    ten %= 2019;
    mp[now]++;
  }
  ll ans = 0;

  for(auto& e:mp) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define re register
#define ll long long
using namespace std;
inline int read(){
	int k=1,sum=0;
	char c=getchar();
	for(;c<'0' || c>'9';c=getchar()) if(c=='-') k=-1;
	for(;c>='0' && c<='9';c=getchar()) sum=sum*10+c-48;
	return sum*k;
}
int h,w,n;
ll ans[1000000],anss;
typedef pair<int,int> p;
map<p,int> a;
map<p,int>::iterator it;
int main(){
	h=read(),w=read(),n=read();
	for(re int i=1;i<=n;++i){
		int x=read(),y=read();
		for(re int s=max(1,x-2);s<=min(h-2,x);++s){
			for(re int t=max(1,y-2);t<=min(w-2,y);++t){
				++a[p(s,t)];
			}
		}
	}
	int s=0;
	for(it=a.begin();it!=a.end();++it){
		++ans[it->second];++s;
		//cout<<it->second<<" ";
	}
	anss=1ll*(h-2)*(w-2)-s;
	cout<<anss<<endl;
	for(re int i=1;i<=9;++i) cout<<ans[i]<<endl;
	return 0;
}
/*
6 3
2 3
1 2 
1 4 
4 5 
4 6 
0 2 5 1 2 3 
1 5 
1 3 
2 6 
*/

Measured memory_bytes: 56448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long int;
  
int ssum[100],tsum[100];
map<int,int> sprod[100],tprod[100];
vector<int> tint;
  
const int nmax=10000010;
int sum[nmax];
ll prod[nmax];

int main(void){
    string d;
    cin >> d;
    int n=d.size();
    int s=n/2,t=n-s;
    
    ll ns=1,nt=1;
    rep(loop,s) ns*=10;
    rep(loop,t) nt*=10;

    int d_sum=0,dt_sum=0;
   	ll  d_prod=1LL,dt_prod=1LL;

    rep(i,n){
        int cur=d[i]-'0';
        d_sum+=cur;
        d_prod*=(cur+1);
    }

    rep(i,t){
        int cur=d[i+s]-'0';
        dt_sum+=cur;
        dt_prod*=(cur+1);
    }
 	

    rep(i,nt){
        int cur=i;
        sum[i]=0; 
        prod[i]=1LL;
        rep(j,t){
            int dd=cur%10;
            sum[i]+=dd;
            prod[i]*=(dd+1);
            cur/=10;
        }    
    }

    rep(i,nt){ 
        tsum[sum[i]]++;
        tprod[sum[i]][prod[i]]++;
        if(dt_sum==sum[i]&&dt_prod==prod[i]) tint.emplace_back(i);
    }
  	

    ll ans=0LL;
    int ds=0,dt=0;
    rep(i,s) ds=10*ds+d[i]-'0';
    rep(i,t) dt=10*dt+d[s+i]-'0';
  	
	if(ns!=nt) 
		rep(i,ns) ssum[sum[i]]++,sprod[sum[i]][prod[i]]++;
	else
		rep(i,100) ssum[i]=tsum[i],sprod[i]=tprod[i];
    rep(i,ds) if(d_sum-sum[i]>=0&&d_prod>=prod[i]&&d_prod%prod[i]==0) ans+=1LL*tprod[d_sum-sum[i]][d_prod/prod[i]];

    
    rep(i,9*s+1)rep(j,9*t+1){
    	if(i+j>d_sum) break;
    	if(i+j<d_sum) 
    		ans+=1LL*ssum[i]*tsum[j];
    	else{
    		for(auto &k:sprod[i]){
    			for(auto &l:tprod[j]){
  	      			if(1LL*k.first*l.first<d_prod) 
  	      				ans+=1LL*k.second*l.second;
  	      		} 
        	}
    	}
    }
	
    sort(tint.begin(),tint.end());
    ll idx=lower_bound(tint.begin(),tint.end(),dt)-tint.begin();
    ans+=idx;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 121184
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    string sa,sb,sc; cin >>sa>>sb>>sc;

    int i=0, j=0, k=0;
    char c = 'a';
    while (i <= sa.length() && j <= sb.length() && k <= sc.length()) {
        if (c == 'a') {
            c = sa[i];
            i++;
        } else if (c == 'b') {
            c = sb[j];
            j++;
        } else {
            c = sc[k];
            k++;
        } 
    }

    if (i-1 == sa.length()) {
        cout << "A" << endl;
    } else if (j-1 == sb.length()) {
        cout << "B" << endl;
    } else {
        cout << "C" << endl;
    }
    
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    // 100 / 0.8 = 1,250

    int a, b; cin >> a >> b;
    rep(i, 1251) {
        if (floor(i*0.08)==a && floor(i*0.1)==b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main(void) {
    int X, N;
    cin >> X >> N;
    vector< int > p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    vector< bool > q(500);
    for (int i = 0; i <= 200; i++) {
        q[i] = false;
    }
    for (int i = 0; i < N; i++) {
        q[p[i]] = true;
    }
    int m = 2000, n = 2000;
    for (int i = X; i <= 101; i++) {
        if (!q[i]) {
            m = i;
            break;
        }
    }
    for (int i = X; i >= 0; i--) {
        if (!q[i]) {
            n = i;
            break;
        }
    }
    if (n == 2000) {
        n = -1;
    }
    int ans;
    if (abs(X - n) <= abs(X - m)) {
        ans = n;
    } else {
        ans = m;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 3724
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
typedef int TInt;
typedef std::vector<TInt> TList;
TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
int main()
{
    TList Values = Input();
    assert(Values.size() >= 2);
    TInt Profit = Values[1] - Values[0];
    TInt Min = std::min(Values[1], Values[0]);
    for(std::size_t i = 2; i < Values.size(); ++i){
        const TInt& V = Values[i];
        TInt P = V - Min;
        if(P > Profit){
            Profit = P;
        }
        if(V < Min){
            Min = V;
        }
    }
    std::cout << Profit << std::endl;
    return 0;
}

Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e5;

int N, K;

int main() {

    cin >> N >> K;
    N++;
    bool ans = (N/2 >= K);
    cout << (ans?"YES":"NO") << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main ()
{
    int s,rem,div,sum=0,x;
    cin>>s;
    x=s;
    while(s!=0)
    {
        rem=s%10;
        s=s/10;
        sum+=rem;
    }
    x=x%sum;
    if(x==0)
    {
        cout<<"Yes"<<endl;
    }

    else
    {
        cout<<"No"<<endl;
    }






}


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

int main(){

    int N;  
    cin >> N ;
    int AC=0,WA=0,TLE=0,RE=0;
    string C;
    for(int i = 0;i < N;i++){
        cin >> C;
        if(C.find("AC")!=std::string::npos){
            AC++;
        }else if(C.find("WA")!=std::string::npos){
            WA++;
        }else if(C.find("TLE")!=std::string::npos){
            TLE++;
        }else if(C.find("RE")!=std::string::npos){
            RE++;
        }
    }

    cout << "AC" << " x " << AC << endl;
    cout << "WA" << " x " << WA << endl;
    cout << "TLE" << " x " << TLE << endl;
    cout << "RE" << " x " << RE << endl;


}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

ll calc_diff(vll& c, vll& x) {
	int n = x.size();
	int m = c.size();
	vector<vll> dp(n+1, vll(256, INFL));
	dp[0][128] = 0;
	rep(i, n) rep(j, 256) rep(k, m) {
		int l = j + c[k];
		if(l < 0) l = 0;
		else if(l > 255) l = 255;
		dp[i+1][l] = min(dp[i][j] + (l-x[i])*(l-x[i]), dp[i+1][l]);
	}
	ll ret = INFL;
	rep(j, 256) ret = min(dp[n][j], ret);
	return ret;
}

int main() {
//	cout << fixed << setprecision(15);
	vll ans, c, x;
	while(true) {
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		c = vll(m);
		rep(i, m) cin >> c[i];
		x = vll(n);
		rep(i, n) cin >> x[i];
		ans.push_back(calc_diff(c, x));
	}
	for(auto i : ans) cout << i << endl;
}



Measured memory_bytes: 43748
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TemplateAlgorithm
{
    class Program
    {
        public const long Inf = (long)1e18;
        public const double eps = 1e-6;
        public const string alfa = "abcdefghijklmnopqrstuvwxyz";
        public const string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const int MOD = 1000000007;


        static void Main(string[] args)
        {
            string s = IO.ReadStr();

            int yy, mm;
            yy = int.Parse(s.Substring(0, 2));
            mm = int.Parse(s.Substring(2, 2));

            if ((1 <= yy && yy <= 12) && (1 <= mm && mm <= 12))
            {
                IO.Cout("AMBIGUOUS");
            }
            else if ((1 <= mm && mm <= 12))
            {
                IO.Cout("YYMM");
            }
            else if ((1 <= yy && yy <= 12))
            {
                IO.Cout("MMYY");
            }
            else IO.Cout("NA");
        }

        static int ToInt(char c) => c - '0';



        #region MIN,MAX

        /// <summary>
        /// 最大値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MaxValue<T>(params T[] vals) => vals.Max();

        /// <summary>
        /// 最小値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MinValue<T>(params T[] vals) => vals.Min();
        #endregion
    }

    #region IO

    /// <summary>
    /// IO
    /// </summary>
    public class IO
    {
        public static string ReadStr(bool isTrim = false) => (isTrim) ? ReadLine().Trim() : ReadLine();
        public static int ReadInt() => int.Parse(ReadStr());

        public static long ReadLong() => long.Parse(ReadStr());

        public static decimal ReadDecimal() => decimal.Parse(ReadStr());
        public static double ReadDouble() => double.Parse(ReadStr());
        public static string[] ReadStrArr(char separator = ' ') => ReadLine().Split(separator);
        public static int[] ReadIntArr() => Array.ConvertAll(ReadStrArr(), int.Parse);
        public static long[] ReadLongArr() => Array.ConvertAll(ReadStrArr(), long.Parse);

        public static decimal[] ReadDecimalArr() => Array.ConvertAll(ReadStrArr(), decimal.Parse);
        public static double[] ReadDoubleArr() => Array.ConvertAll(ReadStrArr(), double.Parse);

        public static void Cout<T>(T value) => WriteLine(value);
        public static void CoutJoin<T>(T[] values, string separator = " ") => Cout(string.Join(separator, values));
    }

    #endregion    
}


Measured memory_bytes: 13140
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int sx = sc.nextInt() -1;
        int sy = sc.nextInt() -1;
        int gx = sc.nextInt() - 1;
        int gy = sc.nextInt() -1;
        boolean[][] g = new boolean[h][w];
        for(int i=0; i<h; i++) {
            char[] cc = sc.next().toCharArray();
            for(int j=0; j<w; j++) {
                g[i][j] = cc[j] == '.';
            }
        }
        if(sx == gx && sy == gy) {
            System.out.println(0);
            return;
        }
        boolean[][] v = new boolean[h][w];
        boolean[][] vd = new boolean[h][w];
        boolean[][] vn = new boolean[h][w];
        Queue<P> q = new LinkedList<>();
        Queue<P> nq = new LinkedList<>();
        int warp = 0;
        q.add(new P(sx, sy));
        while(true) {
            while(!q.isEmpty()) {
                P p = q.poll();
                if(vd[p.x][p.y]) continue;
                vd[p.x][p.y] = true;
                if(p.x == gx && p.y == gy) {
                    System.out.println(warp);
                    return;
                }
                for(int dx = -2; dx <= 2; dx++) {
                    int nx = p.x + dx;
                    if(nx < 0 || h <= nx) continue;
                    for(int dy = -2; dy <=2; dy++) {
                       int ny = p.y + dy;
                       if(ny <0 || w <= ny) continue;
                       if(!g[nx][ny]) continue;
                       int dd = Math.abs(dx) + Math.abs(dy);
                       if(dd == 0) continue;
                       if(dd == 1) {
                           if(v[nx][ny]) {
                               continue;
                           }
                           v[nx][ny] = true;
                           q.add(new P(nx, ny));
                           v[nx][ny] = true;
                       } else {
                           if(v[nx][ny] || vd[nx][ny] || vn[nx][ny]) continue;
                           nq.add(new P(nx, ny));
                           vn[nx][ny] = true;
                       }
                    }
                }
            }
            warp++;
            if(nq.isEmpty()) {
                System.out.println(-1);
                return;
            }
            q = nq;
            nq = new LinkedList<P>();
        }

    }
    static class P {
        int x;
        int y;
        P(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }





}

Measured memory_bytes: 62052
#include <bits/stdc++.h>
using namespace std;
 
struct Node{
    int key;
    Node *right, *left, *parent;
};
 
Node *root, *NIL;

void find(int k){
//    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    bool exist = false;
    while(x != NIL){
        if(z->key == x->key) {
            exist = true;
            break;
        }else if(z->key > x->key){
            x = x->right;
        }else{
            x = x->left;
        }
    }
    cout << (exist ? "yes" : "no") << endl;
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
     
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
     
    while( x != NIL ){
        y = x;
        if(z->key > x->key){
            x = x->right;
        }else{
            x = x->left;
        }
    }
    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}
 
void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}
 
void preorder(Node *u){
    if(u == NIL) return;
    cout <<  " " << u->key;
    preorder(u->left);
    preorder(u->right);
}
 
int main()
{
    int m, i, x;
    string s;
    cin >> m;
    for(i = 0; i < m; i++){
        cin >> s;
        if(s == "find"){
            cin >> x;
            find(x);
        }else if(s == "insert"){
            cin >> x;
            insert(x);
        }else if(s == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
             
        }
     
    }
     
 
    return 0;
}


Measured memory_bytes: 26540
n = int(input().strip())
a = list(map(int, input().split()))
two = 0
four = 0
for e in a:
    if e % 4 == 0:
        four += 1
    elif e % 2 == 0:
        two += 1
if (n - two <= 2 * four) or (two == 0 and n <= (2 * four + 1)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62832
#include <bits/stdc++.h>
using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
int INF = 1e9 + 7;

struct node{
  long long white, black;
  node(long long _white, long long _black) {
    white = _white, black = _black;
  }
};

void dfs(int current_node, vector <vector <int>>& asd, vector <node>& v, int prev) {
  if (asd[current_node].size() == 1 && prev != -1) {
    v[current_node] = node(1, 1);
    return;
  }
  long long product = 1, product_2 = 1;
  for (int nextnode: asd[current_node]) {
    if (nextnode == prev) continue;
    dfs(nextnode, asd, v, current_node);
    product *= ((v[nextnode].white + v[nextnode].black) % INF);
    product %= INF;
    product_2 *= v[nextnode].white;
    product_2 %= INF;
  }
  v[current_node].black = product_2;
  v[current_node].white = product;
}

int main(void) {
  int n, a, b;
  cin >> n;
  vector <vector <int>> asd(n);
  ffor(n - 1) {
    cin >> a >> b;
    a--; b--;
    asd[a].push_back(b);
    asd[b].push_back(a);
  }
  
  vector <node> v(n, node(0, 0));
  dfs(0, asd, v, -1);
  
  cout << (v[0].white + v[0].black) % INF;
}

Measured memory_bytes: 18380
n,k,q = gets.split.map(&:to_i)

list = [0]*n
q.times do |i|
  a = gets.to_i
  list[a-1] += 1
end

list.each do |i|
  if i+k-q > 0
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 4860
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int H = Integer.parseInt(sc.next());
        final int W = Integer.parseInt(sc.next());
        
        for (int i = 0; i < W + 2; i++) {
            out.print("#");
        }
        out.println();
        
        for (int i = 0; i < H; i++) {
            String s = sc.next();
            out.println("#" + s + "#");
        }
        
        for (int i = 0; i < W + 2; i++) {
            out.print("#");
        }
        out.println();
        
        out.flush();
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < (N); i++)
#define rem(i, N, s) for(ll i{N}; i > (s); i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n", sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* 約数列挙 */deque<ll> divisor(ll n) {deque<ll> ret;for(ll i = 1; i * i <= n; i++) {if(n % i == 0) {ret.push_back(i);if(i * i != n) ret.push_back(n / i);}}sort(begin(ret), end(ret));return (ret);}/* 最頻値 */template<typename T> auto mode(T data){if(data.size() == 1) return *begin(data);sort(begin(data), end(data));typename decltype(data)::value_type mode{};size_t n{},count{1};for(auto iter = adjacent_find(begin(data), end(data)),last = end(data), next = end(data); iter != last;){next = upper_bound(iter, last, *iter);count = distance(iter,next);if(n < count) n = count, mode = *iter;iter = adjacent_find(next, last);}return mode;}/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N, K;
  cin >> N >> K;
  cout << (N%K>0) << rt;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
cnt = 0
i = 0
while i < n-1:
    for j in range(n-1,i,-1):
        if a[j] < a[j-1]:
            a[j-1],a[j] = a[j],a[j-1]
            cnt += 1
    i += 1
for i in range(n):
    if i != n-1:
        print(a[i], end=' ')
    else:
        print(a[i])
print(cnt)


Measured memory_bytes: 5608
#include<stdio.h>
int main(void){
	int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1){
        c=c-b;
        a=a-d;
        if(c<=0){
            printf("Yes");
            return 0;
        }else if(a<=0){
            printf("No");
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,q,a;
    cin >> n >> k >> q;
    vector<int> score(n, k-q);
    for(int i=0;i<q;i++){
        cin >> a;
        score[--a]++;
    }
    for(int i=0;i<n;i++){
        cout << (score[i] > 0 ? "Yes" : "No" ) << endl;
    }
}

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

int main(){
    long long A, B;
    long long V, W;
    long long T;

    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    if(V <= W){
        cout << "NO" << endl;
        return 0;
    }

    long long l = A-B;
    if(l<0){
        l *= -1;
    }

    long long v = V-W;

    if( v*T < l){
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
}

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



int main() {
  
  int X, N;
  scanf("%d %d", &X, &N);

  if(N==0){
    printf("%d\n", X);
    return 0;
  }

  vector<int> p(N);
  for(int i=0;i<N;i++){
    scanf("%d", &p[i]);
  }
  
  int N_MAX = 100;
  vector<int> v(N_MAX+1);
  for(int i=0;i<N;i++){
    v[p[i]]=1;
  }
  
  for(int i=0;i<N+1;i++){
    if(X-i<0){printf("%d\n", -1);break;}
    if(v[X-i]==0){printf("%d\n", X-i);break;}
    if(X+i>N_MAX){printf("%d\n", N_MAX+1);break;}
    if(v[X+i]==0){printf("%d\n", X+i);break;}    
  }

  return 0;
}




Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;



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

	int yes = 0;

	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i*j == N) {yes = 1; }
		}

		
	}

	if (yes == 1) { cout << "Yes"; }
	if (yes == 0) { cout << "No"; }
	system("PAUSE");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 1000000007;
// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

ll pmod(ll x, ll y) {
  if (y == 0) return 1;
  if ((y%2) == 1) return pmod(x,y-1)*x%MOD;
  ll h=pmod(x,y/2);
  return h*h%MOD;
}
constexpr ll m = 300000;
ll fact[m+1];
ll ifact[m+1];

ll comb(ll n, ll k) {
  return fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}

int main() {
  fact[0] = 1;
  REP(i,m) {
    fact[i+1] = fact[i] * (i+1) % MOD;
  }
  ifact[m] = inv(fact[m], MOD);
  REP(i,m) {
    int j = m - i;
    ifact[j-1] = ifact[j] * j % MOD;
  }
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,a,b,c;
  cin>>n>>a>>b>>c;
  ll mul = 100 * inv(100-c, MOD) % MOD;
  ll x = a * inv(a+b, MOD) % MOD;
  ll y = b * inv(a+b, MOD) % MOD;
  ll ans = n;
  ll sum = 1;
  REP(i,n-1) {
    sum += MOD - comb(n+i-1, i) * pmod(x, i) % MOD * pmod(y, n) % MOD;
    sum += MOD - comb(n+i-1, i) * pmod(x, n) % MOD * pmod(y, i) % MOD;
    sum %= MOD;
    ans += sum;
    ans %= MOD;
  }
  ans *= mul;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#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(){
  string s, t;
  cin >> s >> t;
  if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0]) co("YES");
  else co("NO");
  
  return 0;
}


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

int main() {
  
  int H, W;
  cin >> H >> W;
  while ( H != 0 && W != 0) {
  
    for (int i=0; i<H; i++) {
      cout << '#';
	  for (int j=0; j<W-2; j++) {
        if (i==0 || i==H-1) {
	 	  cout << '#';
        } else {
	      cout << '.';
        }
      }
      cout << '#' << endl;
    }
    
    cout << endl;
    cin >> H >> W;
  }
  
  return 0;
}



Measured memory_bytes: 3072
/************************************************
*Author        :  lrj124
*Created Time  :  2019.08.18.20:11
*Mail          :  1584634848@qq.com
*Problem       :  c
************************************************/
#include <bits/stdc++.h>
using namespace std;
priority_queue<double,vector<double>,greater<double> > Q;
int n;
int main() {
	scanf("%d",&n);
	for (int i = 1,x;i <= n;i++) scanf("%d",&x),Q.push(x);
	for (int i = 1;i < n;i++) {
		double a,b; a = Q.top(); Q.pop(); b = Q.top(); Q.pop();
		Q.push((a+b)/2.);
	}
	printf("%.5f",Q.top());
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
 
 
def lcd(a, b):
    return a*b // gcd(a, b)
  
a, b, c, d = map(int, input().split())
sum1 = (a - 1) // c + (a - 1) // d - (a - 1) // lcd(c, d)
sum2 = b // c + b // d - b // lcd(c, d)
print(b - a  + 1 - (sum2 - sum1))

Measured memory_bytes: 3188
#include <iostream>

#define P 1000000007
#define N_MAX 100002

using namespace std;

long inv[N_MAX],fac[N_MAX],finv[N_MAX];
 
long comb(long n, long r){
  long ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%P;
      ans = (ans*finv[n-r])%P;
      ans = (ans+P)%P;
  }
  return ans;
}

void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=P-inv[P%i]*(P/i)%P;
        fac[i]=fac[i-1]*(long) i%P;
        finv[i]=finv[i-1]*inv[i]%P;
    }
}

int main(){
    int n;
    int cnt[100001] = {0};
    int a[100001];
    int l = -1, r;
    int d_num;
    make();
    cin >> n;
    for(int i = 0; i <= n; i++){
        //int a;
        cin >> a[i];
        cnt[a[i]]++;
        if(cnt[a[i]] == 2) {
            d_num = a[i];
            break;
        }
    }
    for(int i = 0; i <= n; i++){
        if(a[i] == d_num){
            if(l == -1) l = i+1;
            else r = i+1;
        }
    }
    
    for(int i = 1; i <= n+1; i++){
        cout <<  ((comb(n+1, i) - comb(n-r+l,i-1))%P+P)%P << endl;
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

int main()
{
    int i,j;
  int n; cin >> n;
  double x[n+1]={}; int y[n+1]={};
  rep(i,n){cin >> x[i+1] >> y[i+1];}
  double ans = 0;
  double div = 1;
  for(i=1;i<=n;i++){div *= i;}

  vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    do {
        rep(i,n-1){
            ans += (double)std::sqrt((x[v[i+1]] - x[v[i]]) * (x[v[i+1]] - x[v[i]]) + (y[v[i+1]] - y[v[i]]) * (y[v[i+1]] - y[v[i]]));
        }
    } while( next_permutation(v.begin(), v.end()) );
  
  cout << std::fixed;
  cout << std::setprecision(10) << ans / div << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input());R,d,f,s,x=sorted(list(map(int,input().split()))for i in range(N))+[(2e9,0)],[0]*N+[1],[0]*N,1,N
for i in range(N-1,-1,-1):
	while R[x][0]<sum(R[i]):x=f[x]
	d[i]=s=(s+d[x])%998244353;f[i],x=x,i
print(d[0])

Measured memory_bytes: 64044
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,m;
int tot,bian[N],nxt[N],head[N];
void add(int x,int y){
    ++tot,bian[tot]=y,nxt[tot]=head[x],head[x]=tot;
}
int s,t;
int d[N][3];
int v[N][3];
queue<pair<int,int> >q;
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
	}
	cin>>s>>t;
    memset(d,0x3f,sizeof d);
    int inf=d[0][0];
    d[s][0]=0;
    q.push(make_pair(s,0));
    while(!q.empty()){
        int x=q.front().first,id=q.front().second;
        q.pop();
	    for(int i=head[x];i;i=nxt[i]){
	        int y=bian[i];
	        if(v[y][(id+1)%3])continue;
		    v[y][(id+1)%3]=1;
		    d[y][(id+1)%3]=d[x][id]+1;
		    q.push(make_pair(y,(id+1)%3));
		}
	}
	if(d[t][0]==inf){
	    puts("-1");
	}else{
	    cout<<d[t][0]/3<<endl;
	}
}

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>

using ll = long long;

using namespace std;

int diagram[40010] = {0};
int main() {
    int n;
    cin >> n;
    int t[n], v[n];
    for (auto &ti:t) cin >> ti;
    for (auto &vi:v) cin >> vi;
    int j = 0;
    for (int i=0, s; i<n; i++) {
        s = j;
        for (; j<s+t[i]*2; j++) {
            diagram[j] = v[i] * 2;
        }
    }
    int prev = 0;
    for (auto &d:diagram) {
        d = min(prev+1, d);
        prev = d;
    }
    for (int i=0, s=0; i<n; i++) {
        s += t[i] * 2;
        if (i < n-1 && diagram[s-1] <= 2 * v[i+1]) continue;
        diagram[s] = diagram[s-1] = (i < n-1 ? v[i+1] * 2 : 0);
    }
    reverse(diagram, diagram+40010);
    prev = 0;
    long ans = 0;
    for (auto &d:diagram) {
        prev = min(prev+1, d);
        //cerr << prev << endl;
        ans += prev;
    }
    cout << setprecision(15) << (double)ans / 4  << '\n';
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, B, C;

  cin >> A >> B >> C;

  cout << A+B+C+max(A, max(B, C))*9 << "\n";

  return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c){
        cout << "Yes";
    } else if(a == c && a != b){
        cout << "Yes";
    } else if(b == c && a != b){
        cout << "Yes";
    } else {
        cout << "No";
    }
}


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


int dfs(string s){
    //cerr<<s<<endl;
    vector<int> ret;
    int n=s.size();
    if(s[0]!='['){
        int k=0;
        for(int i=0;i<n;i++){
            k*=10;
            k+=(int)s[i]-'0';
        }
        //cerr<<k<<endl;
        ret.push_back(k/2+1);
    }
    else {
        int cnt=0;
        int l=0;
        for(int i=0;i<n;i++){
            if(s[i]=='['){
                if(cnt==0) l=i+1;
                cnt++;
            }
            else if(s[i]==']'){
                cnt--;
                if(cnt==0){
                    int get=dfs(s.substr(l,i-l));
                    ret.push_back(get);
                    //cerr<<get<<endl;
                }
            }
        }
    }
    sort(ret.begin(),ret.end());
    int sum=0;
    for(int i=0;i<(ret.size()+1)/2;i++){
        sum+=ret[i];
        //cerr<<ret[i]<<endl;
    }
    return sum;

}


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

    int n;
    cin>>n;
    string s;
    for(int qu=0;qu<n;qu++){
        cin>>s;
        int ans=dfs(s);
        
        cout<<ans<<endl;

    }
}


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

int main() {
    int N; cin >> N;
    unordered_map<ll, ll> m;
    ll s = 0;
    for (int i = 0; i < N; ++i) {
        ll a; cin >> a; m[a]++;
        s += a;
    }
    int Q; cin >> Q;
    for (int i = 0; i < Q; ++i) {
        ll b, c; cin >> b >> c;
        s += (c - b) * m[b];
        m[c] += m[b];
        m[b] = 0;
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 7092
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  sort(a, a+3);
  cout << a[2] - a[0] << endl; 
  return 0;
}



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

using LL = long long;
  
int main() {
  int N;
  cin >> N;
  long long c = 0;
  for(int i=1; i< N; i++){
    c = c + i;
  }
  cout << c;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, M; cin >> N >> M;
    vvll v(N, vll(N, inf));
    vvll next(N, vll(N));
    rep(i, N) rep(j, N) next[i][j] = j;
    rep(i, M) {
        ll a, b, c; cin >> a >> b >> c;
        a--, b--;
        v[a][b] = c;
        v[b][a] = c;
    }

    for (ll k = 0; k < N; k++)
        for (ll i = 0; i < N; i++)
            for (ll j = 0; j < N; j++)
                if (v[i][k] + v[k][j] < v[i][j]) {
                    v[i][j] = v[i][k] + v[k][j];
                    next[i][j] = next[i][k];
                }

    set<pair<ll, ll>> st;
    for (ll start = 0; start < N; start++)
        for (ll goal = start + 1; goal < N; goal++) {
            //cout << "start: " << start << ", goal: " << goal << endl;
            for (ll cur = start; cur != goal; cur = next[cur][goal]) {
                //cout << cur << " => " << next[cur][goal] << endl;
                st.insert({min(cur, next[cur][goal]), max(cur, next[cur][goal])});
            }
            //cout << endl;
        }
                

    cout << M - st.size() << endl;
    return 0;
}

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

int main() {
  int A[1000000], n;

  scanf("%d", &n);

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

  int q, k, sum = 0;

  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    scanf("%d", &k);
    if ( *lower_bound(A, A+n, k) == k) sum++;
  }

  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 3552
from collections import Counter

n = int(input())

xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))

for i in range(n): # 高さが0でない情報を探す
    if xyh[i][2] != 0:
        xyh_1 = xyh[i]
        break

for cx in range(101): #Cx 0~100
    for cy in range(101): #Cy 0~100
        h = abs(xyh_1[0] - cx) + abs(xyh_1[1] - cy) + xyh_1[2] # 高さHを求める

        flag = 0
        for i in range(n):
             # 高さHが適切であるか確認
            if xyh[i][2] == max(h - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0):
                flag += 1

        if flag == n:
            print(cx, cy, h)


Measured memory_bytes: 3316
#include <cmath>
#include <iostream>
#include <utility>

using lli=long long;

int main(){
  int Q;
  std::cin >> Q;

  for(int i = 0; i < Q; i++){
    lli A,B;
    std::cin >> A >> B;
    if(A>B) std::swap(A,B);
    if(A == B){
      std::cout << 2*A-2 << "\n";
      continue;
    }
    lli m = std::sqrt(A*B);
    if(m*m+m < A*B){
      std::cout << 2*m-1 << "\n";
    }else if(m*m == A*B){
      std::cout << 2*m-3 << "\n";
    }else{
      std::cout << 2*m-2 << "\n";
    }
  }

  return 0;
}



Measured memory_bytes: 256
// ABC051B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
	int K, S;
	cin >> K >> S;
	int count = 0;
	for (int i = 0; i <= K; i++)	{
		for (int j =0; j <= K; j++)		{
			int z = S - i - j;
			if (0 <= z && z <= K)count++;
		}
	}
	cout << count << endl;
	return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	ll ans=0;
	for (int bit = 0; bit < (1<<n-1); ++bit) {
		ll sum = 0;
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				ans += (int)(s[i]-'0');
				if (sum != 0)sum *= 10;
				ans += sum;
				sum = 0;
			}
			else {
				sum *= 10;
				sum += ((int)(s[i] - '0'));
			}
		}
		ans += sum;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

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

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int ma = 0;
    rep(i, N) {
        if (S[i] == 'I') x++;
        else x--;
        ma = max(ma, x);
    }
    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cmath>
using namespace std;

const int maxn = 5e5 + 10;
const int inf = 1e9 + 7;

int n, tot;
int a[maxn];
char s[maxn];

void mul(int a[], int &n, int k) {
    int p = 0;
    for (int i = 1; i <= n; i++) {
        p = a[i] * k + p;
        a[i] = p % 10;
        p = p /10;
        tot += a[i];
    }
    if (p) a[++n] = p;
    tot += p;
}

void add(int a[], int &n, int k) {
    int p = k;
    for (int i = 1; i <= n; i++) {
        tot -= a[i];
        a[i] += p;
        p = a[i] / 10;
        a[i] %= 10;
        tot += a[i];
        if (!p) break;
    }
    if (p) a[++n] = p;
    tot += p;
}

int main() {
    scanf("%s", s);
    n = strlen(s);
    for (int i = 1; i <= n; i++) a[i] = s[n - i] - '0';
    mul(a, n, 9);
    for (int i = 1; i <= n; i++) {
        add(a, n, 9);
        if (tot % 9 == 0 && i * 9 >= tot) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 2688
N,W = map(int,input().split())
L = list(list(map(int,input().split())) for i in range(N))

upper = 10**5
dp = [float("inf") for i in range(upper+1)]
dp[0] = 0

for item in range(N) :
    weight_i,value_i = L[item]
    for value in range(upper, value_i-1, -1) :
        if dp[value - value_i] + weight_i <= W :
            dp[value] = min(dp[value], dp[value - value_i] + weight_i)

for value in range(upper, -1, -1) :
    if dp[value] < float("inf") :
        ans = value
        break

print(ans)


Measured memory_bytes: 54144