akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int n, k;
	cin >> n >> k;
	vector<string> p(n);

	vector<pair<int, char>> v;
	map<char, int> mp;

	for (int i = 0; i < n; i++) {
		cin >> p[i];
		mp[p[i][0]]++;
	}
	each(i, mp) {
		v.push_back(make_pair(i.second, i.first));
	}

	if (v.size() < k) {
		cout << 0 << endl; return 0;
	}
	int ans = 0;
	[&]() {
		while (1) {
			sort(all(v));
			reverse(all(v));
			rep(i, k) {
				v[i].first--;
				if (v[i].first < 0)return;
			}
			ans++;
		}
	}();

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
using System;
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using Li = System.Collections.Generic.List<int>;
using Ll = System.Collections.Generic.List<long>;

namespace AtCoder0705
{
	class Program
	{
		static void Main(string[] args)
		{
			C();
		}

		private static void A()
		{
			var n = int.Parse(Console.ReadLine());
			Console.WriteLine((1000 - n % 1000) % 1000);
		}

		private static void B()
		{
			var n = int.Parse(Console.ReadLine());
			var strs = Enumerable.Range(0, n).Select(x => Console.ReadLine()).ToArray().GroupBy(x => x).Select(g => Tuple.Create(g.Key, g.Count())).ToArray();
			var ac = strs.Where(x => x.Item1 == "AC").Select(x => x.Item2).FirstOrDefault();
			var wa = strs.Where(x => x.Item1 == "WA").Select(x => x.Item2).FirstOrDefault();
			var tle = strs.Where(x => x.Item1 == "TLE").Select(x => x.Item2).FirstOrDefault();
			var re = strs.Where(x => x.Item1 == "RE").Select(x => x.Item2).FirstOrDefault();

			Console.WriteLine($"AC x {ac}");
			Console.WriteLine($"WA x {wa}");
			Console.WriteLine($"TLE x {tle}");
			Console.WriteLine($"RE x {re}");
		}


		private static void C()
		{
			var ints = ReadInts();
			var h = ints[0];
			var w = ints[1];
			var k = ints[2];

			var ar = Enumerable.Range(0, h).Select(x => Console.ReadLine().Select(c => c == '#').ToArray()).ToArray();
			var rowCounts = ar.Select(x => x.Count(y => y)).ToArray();
			var columnCounts = Enumerable.Range(0, w).Select(i => Enumerable.Range(0, h).Count(j => ar[j][i])).ToArray();

			var countResult = 0;
			for (int i = 0; i < 1 << (h + w); i++)
			{
				var arCopy = ar.Select(x => x.ToArray()).ToArray();
				for (int j = 0; j < h; j++)
					if ((i & (1 << j)) != 0)
						for (int l = 0; l < w; l++)
							arCopy[j][l] = false;

				for (int j = h; j < w + h; j++)
					if ((i & (1 << j)) != 0)
						for (int l = 0; l < h; l++)
							arCopy[l][j - h] = false;

				var c = arCopy.Sum(x => x.Count(y => y));
				if (c == k)
					countResult++;
			}

			Console.WriteLine(countResult);
		}

		private static int[] ReadInts() => Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
	}
}


Measured memory_bytes: 30328
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll d,t,s; cin>>d>>t>>s;
	if(d<=t*s)cy;
	else cn;
}

int main()
{
	solve();
}
/*




*/


Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

int main() {
  char c;
  int cnt['z' - 'a' + 1] = {0};
  for ( ; ; ) {
    cin >> c;
    if (!cin.good()) break;
    if (isalpha(c)) {
      ++(cnt[tolower(c) - 'a']);
    }
  }
  for (c = 'a'; c <= 'z'; ++c) {
    cout << c << " : " << cnt[c - 'a'] << endl;
  }
  return 0;
} 



Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
template<class T> inline T sq(T x){return x*x;}


int main(void){
  int n,x[10],y[10];
  int p[]={1,1,2,6,24,120,720,5040,40320}; // n!
  double ans=0;
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> x[i] >> y[i];
  }
  for (int i=0; i<n; i++){
    for (int j=0; j<n; j++){
      ans += sqrt(sq(x[i]-x[j])+sq(y[i]-y[j]))*(p[n-1]);
    }
  }
  ans/=p[n];
  printf("%.14lf\n", ans);  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,a[1000],i,c=1,sum=0;
    scanf("%d%d",&n,&m);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
        if(sum<=m)
            c++;
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
S = input()

# 3桁の数値の総当り
count = 0
for n in range(0, 1000):
    password = "{:03d}".format(n)
    p1, p2, p3 = password

    i1 = S.find(str(p1))
    if i1 < 0:
        continue
    i2 = S[i1+1:].find(str(p2))
    if i2 < 0:
        continue
    i3 = S[i1+1:][i2+1:].find(str(p3))
    if i3 < 0:
        continue
    count += 1
print(count)

Measured memory_bytes: 39920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}

ll mpow(ll x, ll n){//nCrにmodをかけるやり方
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x%mod;
        x = x*x%mod;
        n = n>>1;
    }
    return ans;
}

int main(){
  
  ll X,Y;
  cin>>X>>Y;
  if((X+Y)%3!=0){
    cout<<0<<endl;
  }
else{
  
  ll n=(X+Y)/3;
  
  ll k=(n-abs(X-Y))/2;
  if(k<0){
    cout<<0<<endl;
  }
else{
  
  ll N=1;
  ll K=1;
  ll NK=1;
  for(ll i=1;i<=n;i++){
    N*=i;
    N%=mod;
  }
for(ll i=1;i<=k;i++){
K*=i;
  K%=mod;
}
for(ll i=1;i<=n-k;i++){
NK*=i;
  NK%=mod;
}
  
  cout<<(((N*(mpow(K,mod-2))%mod)*mpow(NK,mod-2)))%mod<<endl;
}
}


}
  
  
  

Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)

using namespace std;

int N;
int H[100005];

int main(void) {
    scanf("%d", &N);
    REP(i, 0, N) scanf("%d", &H[i]);

    int ans = 0;
    int i = 0;
    while (++i < N) {
    	int cnt = 0;

    	while (H[i - 1] >= H[i] && i < N ) {
    		i++;
    		cnt++;
    	}
    	ans = max(ans, cnt);

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

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=2.2e5;
int N;
ll K;
int a[MAXN],pr[MAXN],nx[MAXN],len[MAXN];
ll last[MAXN];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N>>K;
	rep(i,0,N) cin>>a[i];
	
	rep(i,0,N) pr[a[i]]=-1;
	rep(i,0,2*N) {
		int cur=a[i%N];
		if (pr[cur]!=-1 && pr[cur]<N) {
			nx[pr[cur]]=(i+1)%N;
			len[pr[cur]]=i+1-pr[cur];
		}
		pr[cur]=i;
	}
	
	rep(i,0,N) last[i]=-1;
	ll cur=0;
	while (cur<(K-1)*N) {
		if (last[cur%N]!=-1) {
			ll clen=cur-last[cur%N];
			last[cur%N]=-1;
			cur+=((K-1)*N-1-cur)/clen*clen;
		} else {
			last[cur%N]=cur;
			cur+=len[cur%N];
		}
	}
	
	map<int,int> pos;
	vector<int> s;
	rep(i,int(cur%N),N) {
		int p=pos[a[i]];
		if (p<sz(s) && s[p]==a[i]) {
			s.erase(begin(s)+p,end(s));
		} else {
			s.push_back(a[i]);
			pos[a[i]]=sz(s)-1;
		}
	}
	
	rep(i,0,sz(s)) cout<<s[i]<<" \n"[i+1==sz(s)];
}


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

int main() {
  int N;
  cin >> N;
  #define size N
  string s[size];
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  long long int march[5];
  for (int i = 0; i < 5; i++) {
    march[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    switch(s[i][0]) {
      case 'M': march[0]++; break;
      case 'A': march[1]++; break;
      case 'R': march[2]++; break;
      case 'C': march[3]++; break;
      case 'H': march[4]++; break;
      default: break;
    }
  }
  long long int ans = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans +=  march[i] * march[j] * march[k];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <string>
#include <string.h>

using namespace std;

long long solve(const vector<int>& a, bool s)
{
    long long cnt = 0;
    long long sum = a[0];
    if (s) {
        if (sum <= 0) {
            cnt += -(sum - 1);
            sum = 1;
        }
    } else {
        if (sum >= 0) {
            cnt += (sum + 1);
            sum = -1;
        }
    }

    for (size_t i = 1; i < a.size(); ++i) {
        long long sum2 = sum + a[i];
        if (sum < 0) {
            if (sum2 <= 0) {
                cnt += -(sum2 - 1);
                sum2 = 1;
            }
        } else {
            if (sum2 >= 0) {
                cnt += (sum2 + 1);
                sum2 = -1;
            }
        }
        sum = sum2;
    }

    return cnt;
}

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

    vector<int> a;
    for (int i = 0; i < N; ++i) {
        int ai;
        cin >> ai;
        a.push_back(ai);
    }


    cout << min(solve(a, true), solve(a,false)) << endl;

    return 0;
}

Measured memory_bytes: 892
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	h, w := getInt(), getInt()

	var ans int
	if (h == 1) || (w == 1) {
		ans = 1
	} else {
		h1, h2 := (h+1)/2, h/2
		w1, w2 := (w+1)/2, w/2

		ans = h1*w1 + h2*w2
	}

	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
function Main(s){
  s = s.split("\n");
  var n = s[0].split(" ").map(a=>+a);
  var m = n[1];
  n = n[0];
  var b = Array(n).fill(0).map(a=>Array(n).fill(1));
  for(var i = 0; i < m; i++){
    var a = s[i+1].split(" ").map(a=>a-1);
    b[a[0]][a[1]] = b[a[1]][a[0]] = 0;
  }
  var c = Array(n).fill(0);
  var z = 0;
  var x = [], y = [];
  for(i = 0; i < n; i++){
    if(c[i])continue;
    x[z] = 0;
    y[z] = 0;
    c[i] = 1;
    var a = [];
    for(var j = i+1; j < n; j++){
      if(b[i][j]){x[z] = 1; a.push(j);}
    }
    if(a.length){
      if(f(a,1)){console.log(-1); return;}
    }else x[z] = 1;
    z++;
  }
  var d = Array(n).fill(0);
  d[x[0]] = d[y[0]] = 1;
  for(i = 1; i < x.length; i++)
  for(j = n-1; j >= 0; j--){
    if(d[j]){d[j] = 0; d[j+x[i]] = 1; d[j+y[i]] = 1;}
  }
  var k = 0;
  for(i = 0; i < n; i++){
    if(d[i])k = Math.max(k, Math.min(i, n - i))
  }
  console.log(k*(k-1)/2+(n-k)*(n-k-1)/2);
  
  function f(p,q){
    if(!p.length)return;
    var a = [];
    for(var i = 0; i < p.length; i++){
      if(c[p[i]])continue;
      c[p[i]] = 1;
      if(q)y[z]++;else x[z]++;
      for(var j = i+1; j < p.length; j++){
        if(c[p[j]])continue;
        if(b[p[i]][p[j]])return 1;
      }
      for(j = 0; j < n; j++)if(b[p[i]][j])a.push(j);
    }
    if(f(a, q^1))return 1;;
  }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 59160
#include <stdio.h>

int main(void) {
  int l, a, b, c, d;
  scanf("%d%d%d%d%d", &l, &a, &b, &c, &d);
  a = (a + c - 1) / c, b = (b + d - 1) / d;
  int m = a > b ? a : b;
  printf("%d\n", l - m);
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, k; cin>>n>>k;
    vector<int> a(n);
    int id, amin=1e9;
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]<amin){
            amin=a[i];
            id=i;
        }
    }
    cout << (n-1+k-2)/(k-1) << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static int[] n;
    public static int m;
    public static String s;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] count=new int[128];
        while(sc.hasNext()){
            s=sc.nextLine().toLowerCase();
            for(int i=0;i<s.length();i++){
                count[s.charAt(i)]++;
            }
        }
        for(char c='a'; c<='z' ;c++){
            System.out.println(c+" : "+count[c]);
        }
    }
}



Measured memory_bytes: 26288
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;


int main() {
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] += 32;
    cout << s;
}







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

int main() {

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

  while( true ) {

    int w, h;

    cin >> w >> h;

    if ( w == 0 ) break;

    string input;
    vector< string > map;

    queue<int> qx;
    queue<int> qy;

    for ( int i = 0; i < h; i++ ) {
      cin >> input;
      map.push_back( input );
      for ( int j = 0; j < w; j++ ) {
	if ( map[i][j] == '@' ) {
	  qx.push(j);
	  qy.push(i);
	}
      }
    }

    int ans = 1;

    while( qx.size() > 0 ) {

      int x = qx.front();
      int y = qy.front();
      qx.pop();
      qy.pop();

      for ( int i = 0; i < 4; i++ ) {
	int cx = x + dx[i];
	int cy = y + dy[i];
	if ( cx < 0 || cx >= w || cy < 0 || cy >= h ) continue;
	if ( map[cy][cx] == '.' ) {
	  ans++;
	  map[cy][cx] = '@';
	  qx.push(cx);
	  qy.push(cy);
	}
      }

    }

    cout << ans << endl;

  }

  return 0;

}

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

using namespace std;


void solve() {
    int n, k;
    cin >> n >> k;
    int res = (k==1) ?  0 : n-k;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0; ;
		//int t = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		///int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = int.Parse(Console.ReadLine());

		//int num = vals[0];

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int[] x = parseAry(Console.ReadLine().Split(cs));
		int n = vals[0];
		int st = vals[1];
		int res = 1;
		int mint = int.MaxValue;
		for ( int i = 0; i < n;i++ ){
			mint = Math.Min(mint, Math.Abs(st - x[i]));
		}
		int[] div = divisor(mint);
		for ( int k = 0; k < div.Length; k++ ) {
			int flg = 0;
			for ( int i = 0; i < n; i++ ) {
				if ( ( x[i] - st ) % div[k] != 0 ) { flg = 1; break; }
			}
			if ( flg == 0 ) { res = Math.Max(res, div[k]); }
		}

				Console.WriteLine(res);
		return;
	}



	// 約数の列挙 O(sqrt(n))

	static public int[] divisor(int n) {
		List<int> rev = new List<int>();
		int i = 0;
		for ( i = 1; i * i <= n; i++ ) {	//	i^2
			if ( n % i == 0 ) {
				rev.Add(i);
				if ( i != n / i ) {
					rev.Add(n / i);
				}
			}
		}

		int[] re = new int[rev.Count];
		i = 0;
		foreach ( int t in rev ) {
			if ( i % 2 == 0 ) {
				re[i / 2] = t;
			} else {
				re[re.Length - ( i / 2 ) - 1] = t;
			}
			i++;
		}

		return re;
	}
	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}
	
	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 20576
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for Ai in A:
    r = C
    for a, b in zip(Ai, B):
        r += a * b
    if r > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
module aizu_online_judge;
import std.stdio;
 
int main(){
	for(int i = 1; i <= 9; i++) {
		for(int j = 1; j <= 9; j++) {
 			 writeln(i, "x", j, "=", i * j);	
 		}
	}

 	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>


int main(void)
{
	unsigned long long int n;
	unsigned long long int sum = 0;

	scanf("%lld", &n);

	for (unsigned long long int i = 1; i <= n; i++)
	{
		for (unsigned long long int j = i; j <= n; j += i)
		{
			sum += j;
		}
	}


	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
 
int main(){
    int n,d;cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    rep(i,n){
        rep(j,d)cin>>x[i][j];
    }
    int ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int dis=0;
            rep(k,d){
                dis+=pow(x[i][k]-x[j][k],2);
            }
            double sq=sqrt(dis);
            //cout<<d<<" "<<sq<<endl;
            if(sq==(int)sq)ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
    ll N,K;
    cin >> N >> K;
    double p[N];
    double q[N+1];
    q[0] = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> p[i];
        q[i+1] = q[i] + p[i]; 
    }

    ll maxK = 0;
    ll maxi;
    
    for(ll i = 0; i <= N-K; i++)
    {
        ll tmp = q[i+K] - q[i];
        if(tmp > maxK)
        {
            maxK = tmp;
            maxi = i;
        }
    }

    double count = 0;
    for(ll i = maxi; i < maxi+K; i++)
    {
        double tmp = 0;
        for(double j = 1; j <= p[i]; j++)
        {
            tmp += j;
        }
        tmp /= p[i];
        count += tmp;
    }

    cout << fixed << setprecision(12) << count << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static char s[200001];

int main(void) {
	size_t N;

	scanf("%zu", &N);

	printf("%zu\n", 800 * N - 200 * (N / 15));

	return 0;
}


Measured memory_bytes: 128
n=input()
l=len(n)
if(l==1):
    print(n)
elif(str(int(n)+1)[0]!=n[0]):
    print(int(n[0])+(l-1)*9)
elif(len(str(int(n)+1))==l):
     print((int(n[0])-1)+(l-1)*9)

Measured memory_bytes: 3064
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",if a%500<=b{"Yes"}else{"No"})
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
using P = pair<int,int>;

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    int ans = -1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j] == '#') continue;
            vector<vector<int>> dist(h,vector<int>(w,-1));
            queue<P> que;
            que.push(make_pair(i,j));
            dist[i][j] = 0;
            while(!que.empty()){
                P v = que.front();
              	que.pop();
                int bx = v.first;
                int by = v.second;
                for(int dir = 0;dir<4;dir++){
                    int nx = bx + dx[dir];
                    int ny = by + dy[dir];
                    if(nx>=h||ny>=w||nx<0||ny<0||s[nx][ny] =='#') continue;
                    if(dist[nx][ny] != -1) continue;
                    dist[nx][ny] = dist[bx][by] + 1;
                    que.push(make_pair(nx,ny));
                }
            }

            for(int k=0;k<h;k++){
                for(int l=0;l<w;l++){
                    ans = max(ans,dist[k][l]);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    H, W = [int(item) for item in input().split()]
    N = int(input())
    As = [int(item) for item in input().split()]

    line = []
    for i, val in enumerate(As):
        line += val * [i+1]

    grid = [[] for _ in range(H)]

    for i in range(H):
        if i % 2 == 0:
            grid[i] = line[i*W: W*(i+1)]
        else:
            grid[i] = line[i*W: W*(i+1)][::-1]

    for temp in grid:
        print(*temp)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9352
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<char> s(19);
  for(int i=0;19>i;i++){
    cin>>s.at(i);
  }
  s.at(5)=' ';
  s.at(13)=' ';
  for(int i=0;19>i;i++){
    cout<<s.at(i);
  }
  cout<<endl;
}

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

using namespace std;

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

    for (int i = 1; i < b + 1; ++i) {
        if ((a * i) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>(N);

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		List<Integer> Acopy = new ArrayList<>(A);
		Collections.sort(Acopy);
		int maxValue = Acopy.get(N - 1);
		int nextValue = Acopy.get(N - 2);

		PrintWriter out = new PrintWriter(System.out);
		for (int i = 0; i < N; i++) {
			int a = A.get(i);
			if (a == maxValue) {
				out.println(nextValue);
			} else {
				out.println(maxValue);
			}
		}

		out.flush();
	}

	public static int gcd(int a, int b) {
	    if (b == 0) return Math.abs(a);
	    return gcd(b, a % b);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 48356
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string S;
    cin >> S;

    int count1 = 0, count2 = 0;
    for (int i = 0; i < S.length(); i++) {
        if (i % 2) {
            if (S[i] == '0') {
                count1++;
            } else {
                count2++;
            }
        } else {
            if (S[i] == '0') {
                count2++;
            } else {
                count1++;
            }
        }
    }

    if (count1 < count2) {
        cout << count1 << endl;
    } else {
        cout << count2 << endl;
    }

    return 0;
}


Measured memory_bytes: 512
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}
const double PI = acos(-1);
int solve()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;

	double t = 60*h+m;
	double t1 = ((2*PI)/(12*60))*(t);
	double t2 = (PI/30)*m;

	double dt = min(2*PI - abs(t1-t2),abs(t1-t2));
	// whatis(dt);
	double ans = sqrtl( (a*sin(dt))*(a*sin(dt)) + (b-a*cos(dt))*(b-a*cos(dt)) );
	cout<<setprecision(20)<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ts puts("test  check")
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a) for(it=a.begin();it!=a.end();it++)
#define dzkt int T;cin>>T;while(T--)
#define mst(a,i) memset(a,i,sizeof(a))
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=1e4+10,M=3e4+10,inf=1e9+10,mod=1e9+7;
const db pi=atan(1)*4;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a)%mod; a=(a*a)%mod; b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
ll prime(ll x) {for(ll i=2;i<=sqrt(x+0.5);i++) if(x%i==0) return 0; return 1; }
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'&&ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {s=s*10+ch-'0'; ch=getchar();} return s*f;
}
set<ll> st;
vector<ll> vec;

int ans[N];

int main()
{
    iosks;

    for(int x=1;x<105;x++){
        for(int y=1;y<105;y++){
            for(int z=1;z<105;z++){
                int c=x*x+y*y+z*z+x*y+y*z+x*z;
                if(c<N) ans[c]++;
                else break;
            }
        }
    }
    int n;
    cin>>n;
    xh1(1,n+1) cout<<ans[i]<<endl;

    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    ll n;
    cin >> n;
    cout << n*(n+1)/2-n << endl;
    return 0;
}

Measured memory_bytes: 3600
N = int(input())
T = [0]+list(map(int,input().split()))+[float('inf')]
A = [float('inf')]+list(map(int,input().split()))+[0]
ans = 1
MOD = 10**9+7
for i in range(1,N+1):
    if T[i-1] < T[i]:
        ans *= int(T[i] <= A[i])
    if A[i] > A[i+1]:
        ans *= int(T[i] >= A[i])
    if T[i-1] == T[i] and A[i+1] == A[i]:
        ans *= min(T[i],A[i])
        ans %= MOD
print(ans)

Measured memory_bytes: 19012
import itertools

n=int(input())
p=[int(x) for x in input().split()]
q=[int(x) for x in input().split()]

buf=list(itertools.permutations(range(1,n+1)))

#print(buf)

a=buf.index(tuple(p))+1
b=buf.index(tuple(q))+1

print(abs(a-b))

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

long long int modPow(long long int a, long long int n){//繰り返し自乗法(a^n mod p)。計算量 O(logN)
    long long int p = pow(10, 9) + 7;//任意のp(素数) modのやつで使える 
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return a % p;
    }
    if (n % 2 == 1){ 
        return (a * modPow(a, n - 1)) % p;
    }      
    long long t = modPow(a, n / 2);
    return (t * t) % p;
}

int main(){
    string s;
    cin >> s;
    int count = 0;
    
    if(s == "SSS"){
        count = 0;
    }
    if(s == "RRR"){
        count = 3;
    }
    if(s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR"){
        count = 1;
    }
    if(s == "RRS" || s == "SRR"){
        count = 2;
    }
    cout << count << endl;
}

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

int main(){
  int n, q;
  cin >> n >> q;
  vector<int> A(n);
  copy_n(istream_iterator<int>(cin), n, A.begin());
  
  atcoder::fenwick_tree<int64_t> fw(n);
  for (int i = 0; i < n; i++)
    fw.add(i, A[i]);
  for (int i = 0; i < q; i++){
  	int a, l, r;
    cin >> a >> l >> r;
    if (a == 0)
      fw.add(l, r);
    else
      cout << fw.sum(l, r) << endl;
  }

}

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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] l = new int[2 * n];
		for (int i = 0; i < 2 * n; i++) {
			l[i] = -sc.nextInt();
		}
		Arrays.sort(l);
		int sum = 0;
		for (int i = 0; i < 2 * n; i++) {
			if (i % 2 == 1) {
				sum += l[i];
			}
		}
		System.out.println(-sum);
	}

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


Measured memory_bytes: 9876
#include <stdio.h>
#include <vector>
#include <algorithm>

int main(){
    int N, A, tmp;
    int x[51];

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

    int X = std::max(*std::max_element(&x[1], &x[N]), A);
    long long int dp[N + 1][2 * N * X + 1];

    for(int i = 0; i < N; ++i){
        x[i + 1] -= A;
    }

    for(int j = 0; j <= N; ++j){
        for(int t = 0; t <= 2 * N * X; ++t){
            if (j == 0 && t == N * X) {
                dp[j][t] = 1;
            } else if (1 <= j && 0 <= t - x[j] && t - x[j] <= 2 * N * X){
                dp[j][t] = dp[j - 1][t - x[j]] + dp[j - 1][t];
            } else if (1 <= j && (t - x[j] < 0 || 2 * N * X < t - x[j])){
                dp[j][t] = dp[j - 1][t];
            } else {
                dp[j][t] = 0;
            }
        }
    }

    printf("%lld\n", dp[N][N * X] - 1);

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<string> grids(H);
    for (int i = 0; i < H; i++) {
        cin >> grids[i];
    }
    int ans = 1e7;
    for (int i = 0; i < (1 << H-1); i++) {
        int temp_ans = 0;
        int t = i;

        while (t > 0) {
            if (t % 2 == 1) temp_ans++;
            t /= 2;
        }

        vector<int> counts(H, 0);
        for (int j = 0; j < W; j++) {
            int t = i;

            vector<int> temp(H, 0);
            int l = 0;
            temp[l] += (int)(grids[0][j] == '1');
            for (int k = 1; k < H; k++) {
                if (t & 1) l++;
                t /= 2;
                temp[l] += (int)(grids[k][j] == '1');
            }
            for (int k = 0; k < H; k++) {
                if (temp[k] > K) {
                    temp_ans = 1e7;
                    break;
                } else if (counts[k] + temp[k] > K) {
                    temp_ans++;
                    for (int l = 0; l < H; l++) counts[l] = temp[l];
                    break;
                } else {
                    counts[k] += temp[k];
                }
            }
        }
        ans = min(ans, temp_ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


def solve(x, n, p):
    p = set(p)
    best = -1
    best_diff = abs(x + 1)
    for item in range(501):
        if item not in p and abs(item - x) < best_diff:
            best_diff = abs(item - x)
            best = item
    return best


if __name__ == "__main__":
    x, n = arr_in()
    if n == 0:
        out(x)
        exit()
    p = arr_in()
    out(solve(x, n, p))

Measured memory_bytes: 62084
N, M = map(int, input().split())

MAX = 10**10
dist = [[0 if x == i else MAX for x in range(N)] for i in range(N)]
edge_list = []
for i in range(M):
    a, b, c = map(int, input().split())
    edge = [a, b, c]
    edge_list.append(edge)
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c

#Warshall-Floyd
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

ans = 0
for edge in edge_list:
    a, b, c = edge
    if dist[a-1][b-1] < c:
        ans += 1
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <functional>
using namespace std;

int calc_point(int* cards, int size) {
    int point = 0;
    sort(cards, cards+size, greater<int>());
    for (int i = 0; i < size; i++) {
        if (10 <= *(cards+i) && *(cards+i) <= 13) {
            point += 10;
        } else if (cards[i] != 1) {
            point += cards[i];
        } else {
            int remain_ace = size - i;
            while (remain_ace) {
                if (remain_ace == 1) {
                    if (point <= 10) {
                        point += 11;
                    } else {
                        point += 1;
                    }
                } else {
                    point += 1;
                }
                i++;
                remain_ace--;
            }
        }
    }
    if (point > 21) point = 0;
    return point;
}

#define MAX 1000
int main() {
    string s;
    int hand[MAX]; 
    while (getline(cin, s)) {
        if (s == "0") break;
        int i = 0;
        memset(hand, 0, sizeof(hand));
        istringstream ss; ss.str(s);
        while (ss >> hand[i++]);
        cout << calc_point(&hand[0], i-1) << endl;
    }
    return 0;
}

        

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

int main(){

  int n,a=0;
  cin >> n;
  using si = tuple<string,int,int>;
  vector<si> city(n);
  rep(i,n){ cin >> get<0>(city.at(i)); 
            cin >> a;
            get<1>(city.at(i)) = -a;
            get<2>(city.at(i))=i+1;}
  sort(city.begin(),city.end());
  rep(i,n) cout << get<2>(city.at(i)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;

// 隣接リストで使う辺を表す型
struct BellmanfordEdge
{
    ll to;
    ll cost;
    BellmanfordEdge(ll to, ll cost) :to(to), cost(cost) {}
};

// 戻り値が空配列なら負の閉路を含む
std::vector<ll> Bellmanford(ll s, std::vector<std::vector<BellmanfordEdge>>& connection)
{
    // 2 <= N <= 1000, -10^9 <= cost
    const ll INF = 1000000000001;
    auto n = connection.size();
    auto dist = std::vector<ll>(n, INF);

    // 開始点の距離は0
    dist[s] = 0;

    std::vector<bool> containsCircuit(n, false);
    for (auto i=0; i<n; i++)
    {
        for (auto v=0; v<n; v++)
        {
            if (dist[v] == INF)
                continue;

            for (auto k = 0; k < connection[v].size(); k++)
            {
                auto edge = connection[v][k];
                if (dist[v] + edge.cost < dist[edge.to])
                {
                    dist[edge.to] = dist[v] + edge.cost;

                    // Bellmanford ではグラフの走査回数ごとに始点からN次の点までの最小距離しか考慮できない.
                    // 故に N - 1 回更新すれば各点への最小距離が求まる.
                    // それでも最小距離更新の余地があるなら負の閉路が存在する
                    if (i == n - 1)
                        containsCircuit[v] = true;

                }
            }
        }
    }

    // 閉路がゴール(n番目の頂点)までの経路にあるか
    for (auto v=0; v<n; v++)
    {
        if (!containsCircuit[v])
            continue;

        for (auto k = 0; k < connection[v].size(); k++)
        {
            if (containsCircuit[v])
                containsCircuit[connection[v][k].to] = true;
        }
    }

    return containsCircuit[n - 1] ? std::vector<ll>() : dist;
}

int main()
{
    ll N, M;
    std::cin >> N >> M;
    std::vector<std::vector<BellmanfordEdge>> connection(N, std::vector<BellmanfordEdge>());

    for (auto i=0; i<M; ++i)
    {
        ll from, to, cost;
        std::cin >> from >> to >> cost;
        from--;
        to--;
        connection[from].emplace_back(BellmanfordEdge(to, -cost));
    }

    auto result = Bellmanford(0, connection);
    if (result.empty())
        std::cout << "inf" << std::endl;
    else
        std::cout << -result[N-1] << std::endl;
}


Measured memory_bytes: 3708
//define long long int

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;


struct UnionFind {
  vector<int> data;
  
  UnionFind(int sz){
    data.assign(sz, -1);
  }
  
  bool unite(int x, int y){
    x = root(x), y = root(y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y); //rank?
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  
  int root(int x){
    if(data[x] < 0) return x;
    return data[x] = root(data[x]); //経路圧縮
  }
  
  bool same(int x, int y){
    return root(x) == root(y);
  }
  
  int size(int x){
    return (-data[root(x)]);
  }
};

#define int long long

int n, m, a[101010], b[101010];

signed main(){
  cin >> n >> m;
  rep(i, m){ cin >> a[i] >> b[i]; a[i]--; b[i]--; }
  reverse(a, a + m);
  reverse(b, b + m);
  
  UnionFind uf(n);
  
  long long res[101010] = {};
  long long fubensa = (n * (n - 1)) / 2;
  rep(i, m){
    res[i] = fubensa;
    int ra = uf.root(a[i]), rb = uf.root(b[i]);
    if(uf.same(ra, rb)) continue;
    
    long long sa = uf.size(ra), sb = uf.size(rb);
    long long sino = (sa * (sa - 1LL)) / 2LL;
    long long alice = (sb * (sb - 1LL)) / 2LL;
    long long kalen = ((sa + sb) * (sa + sb - 1LL)) / 2LL;
    fubensa += sino + alice;
    fubensa -= kalen;
    uf.unite(ra, rb);
  }
  reverse(res, res + m);
  rep(i, m) cout << res[i] << endl;
}


Measured memory_bytes: 4096
vn, en, r = map(int,input().split())
# cost = [[float("inf") for _ in range(vn)] for __ in range(vn)] #これだとすごいメモリを食う
cost = [[] for _ in range(vn)]
for _ in range(en):
    s,t,d = map(int,input().split())
    cost[s].append([t,d])

D0 = [float("inf") for i in range(vn)]

import heapq
D0[r] = 0
D = [(0,r)]
heapq.heapify(D)
count = 0
while True:
    v = -1
    # 次のノードを見つけてくる
    if not D:
        break
    new_c, new_v = heapq.heappop(D)
    if D0[new_v] < new_c:
        continue
    D0[new_v] = new_c
    for t,d in cost[new_v]:
        if D0[t] > new_c+d:
            heapq.heappush(D,(new_c+d,t))
            D0[t] = new_c+d

    count += 1

for i in range(vn):
    if not D0[i] == float("inf"):
        print(D0[i])
        continue
    print("INF")


Measured memory_bytes: 100492
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[520][520] = {};
int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			a = a % 2;
			dp[i][j] = a;
		}
	}
	vector<tuple<int, int, int, int>>s;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w-1; j++) {
			if (dp[i][j] != 0) {
				dp[i][j] = 0;
				s.push_back(make_tuple(i+1,j+1,i+1,j+2));
				dp[i][j + 1] = (dp[i][j + 1] + 1) % 2;
			}
		}
	}
	for (int i = 0; i < h-1; i++) {
		if (dp[i][w-1] != 0) {
			s.push_back(make_tuple(i+1, w , i + 2, w));
			dp[i + 1][w - 1] = (dp[i + 1][w - 1] + 1) % 2;
		}
	}
	cout << s.size() << endl;
	for (int i = 0; i < s.size(); i++) {
		int& a = get<0>(s[i]);
		int& b = get<1>(s[i]);
		int& c = get<2>(s[i]);
		int& d = get<3>(s[i]);
		cout << a << " " << b << " " << c << " " << d << endl;;
	}
}

Measured memory_bytes: 5232