akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;
     
int take(int n)
{
  int a=1,i;
  rep(i,n)
    a*=5;
  return a;
}

int main()
{
  int n;
  int i;

  while(1){
    cin>>n;
    if(n==0)break;
    int sum=0;

    for(i=1;i<10;i++){
      if(n/take(i)==0)break;
      sum+=n/take(i);
    }
    cout<<sum<<endl;
  }
}

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int n, m, r;
int dist[210][210];
int R[210];
int res = INF;

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

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

    cin >> n >> m >> r;
    rep(i, r) {
        cin >> R[i];
        --R[i];
    }
    sort(R, R + r);
    rep(i, 210) rep(j, 210) {
        if(i == j) dist[i][j] = 0;
        else dist[i][j] = INF;
    }
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        dist[a][b] = dist[b][a] = c;
    }
    Warshall_Floyd();
    do {
        int cost = 0;
        FOR(i, 1, r) {
            cost += dist[R[i - 1]][R[i]];
        }
        chmin(res, cost);
    }while(next_permutation(R, R + r));
    cout << res << endl;
    return 0;
}

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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
  int N;
  cin >> N;
  if (N == 0){
    cout << 2 << endl;
    return 0;
  }
  if (N==1){
    cout << 1 << endl;
    return 0;
  }
  vector<int64_t> L(N+1);
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i = 2; i < N+1; i++){
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  cout << L.at(N) << endl;;
}

Measured memory_bytes: 256
/*
23280701537353
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
//#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     PT                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
ll n,m;
ll mod=998244353;
ll fact[3000009],Ifact[3000009];
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1)
        return (b%mod*power(((b%mod)*(b%mod))%mod,p/2))%mod;
    else
        return (power(((b%mod)*(b%mod))%mod,p/2))%mod;
}
ll choose(ll t,ll r)
{
    return ((fact[t]*Ifact[t-r])%mod*Ifact[r])%mod;
}
ll calc(ll no,ll no2)
{

    return choose(no+no2-1,no2-1);
}
int main()
{
    cin>>n>>m;
    fact[0]=1;
    for(int i=1;i<=3000000;i++)
        fact[i]=(fact[i-1]*i)%mod;
    Ifact[3000000]=power(fact[3000000],mod-2);
    for(ll i=3000000-1;i>=0;i--)
    {
        Ifact[i]=(Ifact[i+1]*(i+1))%mod;
    }
    int mi=min(n,m);
    ll ans=0;
    for(int i=m%2;i<=mi;i+=2)
    {
       ans=(ans+(choose(n,i)*calc((3*m-i)/2,n)%mod))%mod;
    }
    ll res=0;
    for(int i=2*m+1;i<=3*m;i++)
    {
        res=(res+calc(3*m-i,n-1))%mod;
    }
    res=(res*n)%mod;
    ans=((ans-res)%mod+mod)%mod;
    cout<<ans<<endl;
}





























Measured memory_bytes: 47104
/**
 * @author: shashankchdhry
 * @made:   2020-04-02 17:38:44 
**/
#include <bits/stdc++.h>

using namespace std;

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

    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j <= k; j++)
            if (s - i - j >= 0 && s - i - j <= k)
            {
                ans++;
            }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>

typedef unsigned long long ll;

ll DENOM = 1000000000LL + 7LL;
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    ll ret = s.size();
    for(int i=0; i < s.size(); ++i){
        ret -= (s[i] == t[i]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3468
from collections import deque
def calc(seq):
  score = 0
  for a,b,c,d in array:
    if seq[b-1] - seq[a-1] == c:
      score += d
  return score
  
N,M,Q = map(int,input().split())
array = [ list(map(int,input().split())) for _ in range (Q) ]
ans = 0
que = deque()
for i in range(1,M+1):
  que.append([i])
  
while que:
  seq = que.popleft()
  if len(seq) == N:
    score = calc(seq)
    ans = max(ans,score)
  else:
    for i in range(seq[-1],M+1):
      seq_next = seq + [i]
      que.append(seq_next)
print(ans)

Measured memory_bytes: 23228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main{
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] firstRow = br.readLine().split("\\s");

        // 要素数
        int elementNum = Integer.parseInt(firstRow[0]);
        // 減算する値
        int quantum = Integer.parseInt(firstRow[1]);

        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elementNum; i++) {
            String[] stringArray = br.readLine().split("\\s");
      
            Process process = new Process(stringArray[0],
                    Integer.parseInt(stringArray[1]));
            que.offer(process);
        }

        // 処理合計時間
        int resultTime = 0;
        while (que.size() > 0) {
	    
            Process process = que.poll();
	    
            resultTime += quantum;
	    
            if ((process.processTime = process.processTime - quantum) > 0) {
                que.offer(process);
                continue;
            }
            resultTime += process.processTime;
            System.out.println(process.name + " " + resultTime);
        }

    }

    private final static class Process {   
        public String name = null;
        public int processTime = 0;

        public Process(String name, int processTime) {
            this.name = name;
            this.processTime = processTime;
        }
    }
}



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

int main(){
	int n;
	cin >> n;
	vector<int> data(n);
	for(auto &a:data){
		cin >> a;
	}
	int check = 0;
	for(int i = 0; i < n; i++){
		int count = 0;
		for(int j = 2; j <= sqrt(data[i]); j++){
			if(data[i] % j == 0){
				count++;
				j = data[i];
			}
		}
		if(!count) check++;
	}
	cout << check << endl;
	return 0;
}				

Measured memory_bytes: 3096
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        try (final Scanner sc = new Scanner(System.in)) {
            final String input = sc.nextLine();
            for (int i = 0; i < input.length(); i++) {
                final char c = input.charAt(i);
                if (i % 2 == 0 && c == 'L') {
                    System.out.println("No");
                    return;
                }
                if (i % 2 == 1 && c == 'R') {
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 23124
#include<stdio.h>

int main(void){
  char S[100000];
  int cnt = 0;
  int num;
  
  scanf("%s", S);
  
	for(num = 1; S[num] != '\0'; num++){
    	if(S[num - 1] == S[num]){
      		cnt++;
      		if(S[num] == '0'){
        		S[num] = '1';
      		}
      		else{
        		S[num] = '0';
      		}
    	}
    }

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

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll n,x,m;
	cin >> n >> x >> m;
	
	set<ll> s;
	vector<ll> his;
	ll ans = 0;
	ll a = x;
	ll count;
	s.insert(a);
	ans += a;
	his.push_back(a);
	for(int i=2; i<=m+1; i++){
		a = a*a%m;
		if(a==0){
			cout << ans << endl;
			return 0;
		}
		
		auto it = s.find(a);
		
		if(it == s.end()){
			s.insert(a);
			ans += a;
			his.push_back(a);
		}else{
			count = i-1;
			break;
		}
		if(i == n){
			cout << ans << endl;
			return 0;
		}
	}
	
	ll prev=0,pnum=0;
	for(auto x: his){
		if(x!=a){
			prev += x;
			pnum++;
		}else{
			break;
		}
	}
	
	ll loop = ans - prev;
	vector<ll> sum;
	sum.push_back(0);
	FOR(i, pnum, his.size()){
		sum.push_back(sum.back()+his[i]);
	}
	
	ans = prev + loop*((n-pnum)/(count-pnum)) + sum[(n-pnum)%(count-pnum)];
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6732
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

#define INF 20000000
typedef struct Edge edge;

struct Edge{
  int src,dst,weight;
  Edge(int start,int end,int cost) : src(start),dst(end),weight(cost) {}
};

typedef vector<edge> Edges;

bool operator < (const edge &e,const edge &f){
  return (e.weight != f.weight) ? (e.weight > f.weight) : (e.src != f.src) ? (e.src < f.src) : (e.dst < f.dst);
}

class UnionFind{
public:
  int par[1001];
  int rank[1001];

  UnionFind(){
	for(int i = 0;i < 1001;i++){
	  par[i] = i;
	  rank[i] =1;
	}
  }

  int root(int);
  bool findset(int,int);
  void unionset(int,int);
};

void kruskal(Edges);

int main(int argc,char* argv[]){
  int V;
  Edges es;
  int dist;

  cin >> V;
  for(int i = 0;i < V;i++){
	for(int j = 0;j < V;j++){
	  cin >> dist;
	  if(dist != -1){
		edge e(i,j,dist);
		es.push_back(e);
	  }
	}
  }

  kruskal(es);
  return 0;
}

void kruskal(Edges es){
  priority_queue<edge> que;
  int cost = 0;
  UnionFind uf;
  for(int i = 0;i < (int)es.size();i++)
	que.push(es[i]);

  while(!que.empty()){
	edge e = que.top();que.pop();

	if(!uf.findset(e.src,e.dst)){
	  uf.unionset(e.src,e.dst);
	  cost += e.weight;
	}
  }

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


int UnionFind::root(int x){
  return (par[x] == x) ? x : root(par[x]);
}

bool UnionFind::findset(int x,int y){
  return root(x) == root(y);
}

void UnionFind::unionset(int x,int y){
  x = root(x);
  y = root(y);

  if(x == y)
	return;

  if(rank[y] < rank[x])
	swap(x,y);
  par[y] = x;
  rank[x] += rank[y];
}

Measured memory_bytes: 1532
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int X = Integer.parseInt(st.nextToken()) - 1;
		int Y = Integer.parseInt(st.nextToken()) - 1;
		int[] values = new int[N - 1];
		for (int i = 0; i < N; i++) {
//			System.out.println(i);
			boolean[] visited = new boolean[N];
			List<Integer> bfs = new ArrayList<>();
			bfs.add(i);
			visited[i] = true;
			int depth = 0;
			while (bfs.size() > 0) {
				List<Integer> aux = new ArrayList<>();
				for (int node : bfs) {
					int one = node - 1;
					int two = node + 1;
					if (one >= 0 && !visited[one]) {
						visited[one] = true;
						aux.add(one);
					}
					if (two < N && !visited[two]) {
						visited[two] = true;
						aux.add(two);
					}
					if (node == X && !visited[Y]) {
						visited[Y] = true;
						aux.add(Y);
					}
					if (node == Y && !visited[X]) {
						visited[X] = true;
						aux.add(X);
					}
				}
//				System.out.println(depth + " " + aux.toString());
				values[depth] += aux.size();
				depth++;
				bfs = new ArrayList<>(aux);
			}
		}
		for (int i = 0; i < values.length; i++) {
			System.out.println(values[i] / 2);
		}

//		List<Integer>[] adj = new List[N];
//		for (int i = 0; i < N; i++) {
//			adj[i] = new ArrayList<>();
//		}

	}
}

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

//グローバルなので初期化されている
int dp[5005][5005];

int main(void){
    int n;
    string s;
    cin >> n >> s;
    //後ろからforループを回す
    for(int i=n-1; i >= 0; --i) {
        for(int j=n-1; j>=0; --j) {
            if(s[i]!=s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1]+1; //範囲外があるけど初期化あるので大丈夫
        }
    }
    int ans=0;
    rep(i,n)rep(j,n){
        if(i>=j) continue; // i < j
        int now=min(dp[i][j], j-i);
        ans=max(ans,now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 98048
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,m;
Vi h;
struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;

graph g;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>m;
    g.resize(n);
    h.resize(n);
    rep(i,n){
        cin>>h[i];
    }
    rep(i,m){
        ll in,inp;
        cin>>in>>inp;
        in--;
        inp--;
        g[in].pb(edge(inp));
        g[inp].pb(edge(in));
    }
    ll ans = 0;
    rep(i,n){
        ll nw = h[i];
        bool fg = true;
        rep(j,g[i].size()){
            edge e = g[i][j];
            ll tp = h[e.to];
            if(tp>=nw){
                fg = false;
                break;
            }
        }
        if(fg)ans++;
    }
    print(ans);
    return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;
typedef pair<int, int> pii;

int w, h;
int m[50][50];
int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

void dfs(int nw, int nh){
  REP(i, 8){
    if(nw + dx[i] < 0 or nw + dx[i] >= w or nh + dy[i] < 0 or nh + dy[i] >= h) continue;
    if(m[nw+dx[i]][nh+dy[i]] == 1) { m[nw+dx[i]][nh+dy[i]] = 0; dfs(nw+dx[i], nh+dy[i]); }
  }
  return;
}

int main(){
  while(cin >> w >> h and w + h){
    int res = 0;
    REP(i, h) REP(j, w) cin >> m[j][i];
    REP(i, h) REP(j, w) { if(m[j][i]) { dfs(j, i); res++; } }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3176
#include<iostream>

int main(){
    int K, A, B;
    std::cin >> K >> A >> B;
    if(A%K==0 || A%K+(B-A)>=K){
        std::cout << "OK" << "\n";
    }else{
        std::cout << "NG" << "\n";
    }
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

ll n,a;
ll x[55];
ll dp[55][55][2560];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>a;
	rep(i,n)cin>>x[i];
	dp[0][0][0]=1;
	rep(i,n)rep(j,i+1)rep(k,2501){
		dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
		dp[i+1][j][k]+=dp[i][j][k];
	}
	ll res=0;
	rep(j,n+1)rep(k,2501){
		if(j*a==k){
			res+=dp[n][j][k];
		}
	}
	cout<<res-1<<endl;
	return 0;
}


Measured memory_bytes: 27008
package main

import (
	"fmt"
)

func main() {
	tp := 0
	hp := 0

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var t, h string
		fmt.Scan(&t, &h)

		l := len(t)
		if len(h) < len(t) {
			l = len(h)
		}

		r := 0
		for j := 0; j < l; j++ {
			if t[j] == h[j] {
				continue
			} else if h[j] < t[j] {
				r = 1
				break
			} else if t[j] < h[j] {
				r = 2
				break
			}
		}
		if r == 0 {
			if len(t) == len(h) {
				tp++
				hp++
			} else if len(h) < len(t) {
				tp += 3
			} else if len(t) < len(h) {
				hp += 3
			}
		} else if r == 1 {
			tp += 3
		} else if r == 2 {
			hp += 3
		}
	}
	fmt.Printf("%d %d\n", tp, hp)
}



Measured memory_bytes: 1204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            long[] h = in.nextLongArray(n);
            long[] dp = new long[n];

            dp[0] = 0;
            for (int j = 1; j < n; j++)
                dp[j] = Long.MAX_VALUE;


            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j <= Math.min(n - 1, i + k); j++) {
                    dp[j] = Math.min(dp[j], dp[i] + Math.abs(h[i] - h[j]));
                }
            }

            out.println(dp[n - 1]);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }
}



Measured memory_bytes: 25300
N,K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
s = t = 0
S = A.map{ |a| s += a } + [0]
T = A.map{ |a| t += [a,0].max } + [0]
#p A,S,T

p (0 ... A.size - K + 1).map{ |i|
  #p [i, (T[i-1]), (S[i+K-1] - S[i-1]), (T[-2] - T[i+K-1])]
  (T[i-1]) + [(S[i+K-1] - S[i-1]), 0].max + (T[-2] - T[i+K-1])
}.max


Measured memory_bytes: 15244
import java.util.Scanner;
     
    public class Main {
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = 0;
        for (int i = 0; i < 2; i++) {
          if (a < b) {
            sum += b;
            b--;
          } else {
            sum += a;
            a--;
          }
        }
        System.out.println(sum);
      }
    }

Measured memory_bytes: 23124
#include<stdio.h>
#include<math.h>
 struct Point{double x,y;};

void koch(int,struct Point,struct Point);
int main(){
struct  Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

void koch(int n, struct Point a,struct Point b){
  if(n==0)return;

 struct Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)* cos(th) -(t.y-s.y)* sin(th) +s.x;
  u.y=(t.x-s.x)* sin(th) +(t.y-s.y)* cos(th) +s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);}



Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll N; cin >> N;
    if (N % 1000 == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 1000 - N % 1000 << endl;
    }
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int N, s[110];
    cin >> N;
    rep(i, N) cin >> s[i];
    sort(s, s+N);

    int ans = 0;
    rep(i, N) ans += s[i];
    if (ans % 10 != 0) {
        cout << ans << endl;
        return 0;
    } else {
        rep(i, N) {
            int tmp = ans - s[i];
            if (tmp % 10 != 0) {
                cout << tmp << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}


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

int main(){
  string s;
  cin >> s;
  vector<int> data(s.size() - 2);
  for(int i = 0; i < s.size() - 2; i++){
    int x = (s.at(i) - '0') * 100 + (s.at(i + 1) - '0') * 10 + s.at(i + 2) - '0' ;
    data.at(i) = abs(753 - x);
  }
  sort(data.begin(), data.end());
  cout << data.at(0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define loop(a,b) for(int (b)=0;(b)<(a);(b)++)
using namespace std;
vector<int>a[100001];
int path[100001];
void dfs(int n,int p){
	if(path[n]!=-1)return;
	path[n]=p;
	loop(a[n].size(),i){
		dfs(a[n][i],n);
	}
}
int count(int now,int last,int&stop){
	if(now==stop)return 0;
	int ret=1;
	for(int i=0;i<a[now].size();i++){
		if(a[now][i]!=last)ret+=count(a[now][i],now,stop);
	}
	return ret;
}
int main(){
	int n,x,y;
	cin>>n;
	loop(n-1,i){
		cin>>x>>y;
		a[--x].push_back(--y);
		a[y].push_back(x);
	}
	for(auto&i:path)i=-1;
	dfs(0,-1);
	vector<int>way;
	int now=n-1,length=0;
	while(1){
		now=path[now];
		if(now==0)break;
		way.push_back(now);
		length++;
	}
	now=n-1;
	for(int mid=0;mid<(length>>1);mid++){
		now=path[now];
	}
	int white_s=now,black_s=path[now];
	int Fennec=count(0,-1,white_s),Snuke=count(n-1,-1,black_s);
	puts(Fennec>Snuke?"Fennec":"Snuke");
}

Measured memory_bytes: 11388
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll dp[2][1010];

int main(){
    int n, m;
    cin >> n >> m;
    vi c(m+1), d(m+1);
    rep(i, m) cin >> c[i+1] >> d[i+1]; 
    if(m == 0) {
        cout << n+1 << endl;
        return 0;
    }
    vector<pii> p(m+1);
    rep(i, m+1) p[i] = make_pair(c[i], d[i]);
    sort(all(p));
    rep(i, m+1) {
        c[i] = p[i].fi;
        d[i] = p[i].se;
    }
    {
        rep(i, 1010) {
            dp[1][i] = 1e18;
        }
        REP(i, d[1], 1010) {
            dp[1][i] = i + i - c[1];
        }

    }
    int cur, nxt;
    REP(i, 1, m) {
        cur = i&1;
        nxt = (i+1)&1;
        rep(j, 1010) dp[nxt][j] = 1e18;
        // j番目からk番目まで進んでから、c[i]番目にいく
        rep(j, 1010) if(dp[cur][j] != 1e18) {
            REP(k, d[i+1], 1010) {
                if(j >= k) { // c[i] -> c[i+1]
                    int pos = max(j, c[i+1]);
                    dp[nxt][pos] = min(dp[nxt][pos], dp[cur][j] + c[i+1] - c[i]);
                }
                else { // c[i] -> k -> c[i+1]
                    int pos = max(k, c[i+1]);
                    dp[nxt][pos] = min(dp[nxt][pos], dp[cur][j] + abs(c[i] - k) + abs(k - c[i+1]));
                }
            }
        }
        // rep(j, 20) {
        //     cout << " " << (dp[nxt][j] == 1e18 ? -1 : dp[nxt][j]);
        // }
        // cout << endl;
    }

    ll ans = 1e18;
    rep(i, n+1) {
        ans = min(ans, dp[nxt][i] + n+1-c.back());
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int t;int c=0,c1=0,c2=0,c3=0;
   string s[100000];
   cin>>t;
   for(int i=0;i<t;++i){
    cin>>s[i];
    if(s[i]=="AC")
        c++;
    if(s[i]=="WA")
        c1++;
    if(s[i]=="TLE")
        c2++;

    if(s[i]=="RE")
        c3++;
   }
   cout << "AC x " << c <<endl ;
   cout << "WA x " << c1<<endl;
   cout << "TLE x " << c2<<endl;
   cout << "RE x " << c3 <<endl;

}


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

int main(int argc, char **argv)
{
	int n; cin >> n;

	set<int> s;
	int over_num{0};
	for (int i = 0; i < n; ++i)
	{
		int a; cin >> a;
		if (a >= 3200)
			++over_num;
		else
		{
			s.insert(a/400);
		}
	}

	int max{0}, min{0};

	max = static_cast<int>(s.size()) + over_num;
	if (s.size() == 0) min = 1;
	else
		min = static_cast<int>(s.size());

	std::cout << min << " " << max << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n, x, y;
	cin >> n >> x >> y;
	--x; --y;
	vector<int> ans(n);
	rep (sv, n) {
		vector<int> dist(n, INF);
		queue<int> q;
		auto push = [&](int v, int d) {
			if (dist[v] != INF) return;
			dist[v] = d;
			q.push(v);
		};
		push(sv, 0);
		while(!q.empty()) {
			int v = q.front(); q.pop();
			int d = dist[v];
			if (v - 1 >= 0) push(v - 1, d + 1);
			if (v + 1 < n) push(v + 1, d + 1);
			if (v == x) push(y, d + 1);
			if (v == y) push(x, d + 1);
		}
		rep (i, n) ans[dist[i]]++;
	}
	rep (i, n) ans[i] /= 2;
	for (int i = 1; i <= n - 1; ++i) {
		cout << ans[i] << endl;
	}
	return;
}

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

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  ll n, k; cin >> n >> k;
  vector<ll> a(n); REP(i,n) cin >> a[i];
  ll res = (n+k-2)/(k-1);
  if (n == k) res = 1;
  else if (n % (k-1) == 1) res--;
  if (k == 2) res--;
  cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
using namespace std;

#define max_n 1000
#define max_m 1000
#define max_w 1000
#define max_h 1000
#define INF 1000000000


typedef long long lint;


int main()
{
    //入力
    char a[7];
    char c[7];
    char s[101];
    scanf("%s",a);
    scanf("%s",s);
    scanf("%s",c);
    cout<<'A'<<s[0]<<'C'<<endl;
    
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<ll,ll>
#define endl "\n"

void solve()
{
    ll n,w;
    cin>>n>>w;
    vector<ll>weight(n+1),value(n+1);
    loop(i,0,n)
    cin>>weight[i]>>value[i];
    ll sum_value=0;
    for(auto i:value)
    sum_value+=i;
    vector<ll>dp(sum_value+1,1e18L);
    dp[0]=0;
    // dp[i] --> the minimum weight with value as i
    for(ll item=0;item<n;item++)
    {
        for(ll val=sum_value-value[item];val>=0;val--)
        {
            dp[val+value[item]]=min(dp[val+value[item]],weight[item]+dp[val]);
        }
    }
    ll ans=-1;
    for(ll i=0;i<dp.size();i++)
    {
        
        if(dp[i]<=w)
        ans=max(ans,i);
    }
   
    cout<<ans;
}
int main() {
	// your code goes here
	io;
	
    solve();
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin);
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    int ok=1;
    if(s[a]=='-'){
		for(int i=0;i<a;i++)
			if(s[i]=='-')
				ok=0;
		for(int i=a+1;i<int(s.size());i++)
			if(s[i]=='-')
				ok=0;
	}
	else
		ok=0;
	if(ok)
		puts("Yes");
	else
		puts("No");
	return 0;
}


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

num = [int(i) for i in input()]

for s in range(2**3):
    total = num[0]
    op = [""] * 3
    for i in range(3):
        if (s >> i & 1):
            total += num[i+1]
            op[i] = "+"
        else:
            total -= num[i+1]
            op[i] = "-"
    if (total == 7):
        print("{}{}{}{}{}{}{}=7".format(num[0],op[0],num[1],op[1],num[2],op[2],num[3]))
        break


Measured memory_bytes: 3064
a = int(input())
x = list(map(int, input().split()))
y=[]
z=[]
from collections import Counter
for i in range(a):
    if i%2==0:
        y.append(x[i])
    else:
        z.append(x[i])
y.append(0)
z.append(0)
c= Counter(y)
d = Counter(z)
c1=c.most_common()[0][1]
if c.most_common()[1][0]==0:c2=0
else:c2=c.most_common()[1][1]
d1=d.most_common()[0][1]
if d.most_common()[1][0]==0:d2=0
else:d2=d.most_common()[1][1]
#print(c1,c2,d1,d2)
if c.most_common()[0][0]== d.most_common()[0][0]:
    s = a-max(c1+d2,c2+d1)
    #print(a,c1+d2,c2+d1)
    #print(c)
    #print(d)

else:s= a - c.most_common()[0][1] - d.most_common()[0][1]
print(s)

Measured memory_bytes: 20852
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int n;
	cin >> n;
	VI h(n);
	REP(i,n) cin >> h[i];
	
	int ans = 1;
	bool f = true;
	FOR(i,1,n){
		REP(j,i){
			if (h[i] < h[j]){
				f = false;
				break;
			}
		}
		if (f) ans++;
		f = true;
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
    int a,b,c,i,j=0,k,l;

    cin>>a>>b;
     while(b--)
     {
         cin>>c;
         j+=c;
     }
     k=a-j;
     if(k<0) cout<<"-1"<<endl;
     else cout<<k<<endl;


}


Measured memory_bytes: 3632
//#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 __gnu_pbds;
#define eps 1e-7
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,ll>pii;
const ll mod= 1e9+7;
long double PI = acosl(-1);
const ll infl = 3e18+100;
const int inf = 1e9+100;
const int nmax = 2e5+10;
//const int MAXLG = log2(nmax)+1;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

int a[nmax],b[nmax],c[nmax];

int grid[50][25][15];

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

    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        ll num = 0;
        bool dot = false;
        for(int j=0; j<s.size(); j++){
            if(s[j]=='.') dot = true;
            else{
                int x = s[j]-'0';
                num*=10, num+=x;
                if(dot) c[i]++;
            }
        }
        while(num%5==0 and num) num/=5, b[i]++;
        while(num%2==0 and num) num/=2, a[i]++;
//        cout<<a[i]<<"  "<<b[i]<<"  "<<c[i]<<endl;
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<=9; j++){
            int dorkar = c[i] + j;
            int A = max(0, dorkar - a[i]);
            int B = max(0, dorkar - b[i]);
            ans += grid[A][B][j];
        }
        for(int j=0; j<=a[i]; j++) for(int k=0; k<=b[i]; k++){
            grid[j][k][ c[i] ]++;
        }
    }

    cout<<ans<<endl;

}
/*

*/


Measured memory_bytes: 6044
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){

        int n,r;
        bool cards[4][13];
        char s;
        char suites[]={'S','H','C','D'};

        memset(cards,0,sizeof(cards));

        scanf("%d\n",&n);

        for(int i=0;i<n;i++){
                scanf("%c %d\n",&s,&r);
                switch(s){
                        case 'S':
                                cards[0][r-1] = 1;
                                break;
                        case 'H':
                                cards[1][r-1] = 1;
                                break;
                        case 'C':
                                cards[2][r-1] = 1;
                                break;
                        case 'D':
                                cards[3][r-1] = 1;
                }
        }

        for(int i=0;i<4;i++){
                for(int j=0;j<13;j++){
                        if(cards[i][j]==0)
                                printf("%c %d\n",suites[i],j+1);
                }
        }


        return 0;
}


Measured memory_bytes: 3212
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] cities = new int[m][3];//p, year, no
		int[][] sortedCities = new int[m][];
		for (int i = 0; i < m; i++) {
			cities[i][0] = sc.nextInt();
			cities[i][1] = sc.nextInt();
			sortedCities[i] = cities[i];
		}
		Arrays.sort(sortedCities, new Comparator<int[]>() {
		public int compare(int[] c1, int[] c2) {
			if (c1[0] != c2[0]) {
				return c1[0] - c2[0];
			} else {
				return c1[1] - c2[1];
			}
		}
		});
		int idx = 1;
		sortedCities[0][2] = idx;
		for (int i = 1; i < m; i++) {
			if (sortedCities[i - 1][0] == sortedCities[i][0]) {
				idx++;
			} else {
				idx = 1;
			}
			sortedCities[i][2] = idx;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
			if (cities[i][0] < 10) {
				sb.append("00000");
			} else if (cities[i][0] < 100) {
				sb.append("0000");
			} else if (cities[i][0] < 1000) {
				sb.append("000");
			} else if (cities[i][0] < 10000) {
				sb.append("00");
			} else if (cities[i][0] < 100000) {
				sb.append("0");
			}
			sb.append(cities[i][0]);
			if (cities[i][2] < 10) {
				sb.append("00000");
			} else if (cities[i][2] < 100) {
				sb.append("0000");
			} else if (cities[i][2] < 1000) {
				sb.append("000");
			} else if (cities[i][2] < 10000) {
				sb.append("00");
			} else if (cities[i][2] < 100000) {
				sb.append("0");
			}
			sb.append(cities[i][2]);
			sb.append("\n");
		}
		System.out.print(sb);
		
	}
	
	
}

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

int main()
{
	int A,B,C;
	cin >> A >> B >> C;
	if (A + B >= C) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {

	string s; cin >> s;
	sort(s.begin(), s.end());
	string ans;
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
		ans = "Yes";
	}
	else ans = "No";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
//インクルードファイル一覧
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>


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

	scanf("%d%d%d", &a, &b, &c);

	int sum = a + b + c;

	if (sum >= 22) {
		printf("bust\n");
	}
	else {
		printf("win");
	}

	return 0;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{

    public static int MAX = 500000;
    public static int SENTINEL = 2000000000;
    public static int[] L = new int[MAX / 2 + 2];
    public static int[] R = new int[MAX / 2 + 2];
    public static int cnt;

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] A = new int[MAX];
        cnt = 0;
        String[] in = br.readLine().split(" ");
        for(int i = 0; i < n; i++){
            A[i] = Integer.parseInt(in[i]);
        }

        mergeSort(A, n, 0, n);

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            if(i != 0) sb.append(" ");
            sb.append(A[i]);
        }
        sb.append("\n").append(cnt);
        System.out.println(sb);
    }

    public static void mergeSort(int[] A, int n, int left, int right){
        if(left + 1 < right){
            int mid = (left + right) / 2;
            mergeSort(A, n, left, mid);
            mergeSort(A, n, mid, right);
            merge(A, n, left, mid, right);
        }
    }
  

    public static void merge(int[] A, int n, int left, int mid, int right){
        int n1 = mid - left;
        int n2 = right - mid;
        //System.out.println("yes");                                                  
        for(int i = 0; i < n1; i++) L[i] = A[left + i];
        for(int i = 0; i < n2; i++) R[i] = A[mid + i];
        L[n1] = R[n2] = SENTINEL;
        int i = 0, j = 0;
        for(int k = left; k < right; k++){
            cnt++;
            if(L[i] <= R[j]){
                A[k] = L[i++];
            }else{
                A[k] = R[j++];
            }
        }
    }

}

Measured memory_bytes: 142200
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n, x, y;
    cin >> n >> x >> y;
    x--, y--;

    ll ans[n+1] = {};
    rep(i, n)rep(j, n){
        if(j <= i)continue;

        ll dist;

        //xまではそのままの距離が最短
        if(j <= x)dist = j - i;
        //そのままの距離かスキップした距離の最短
        else dist = min(j-i, abs(x-i)+1+abs(y-j));

        ans[dist]++;
    }

    rep(i, n-1)cout << ans[i+1] << endl;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                      # ll = deepcopy(l)
from heapq import *                     # heappush(hp,x)
from string import *                    # alpha = ascii_lowercase
from random import *                    # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                    # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                   # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                 # minn = -maxsize
from operator import *                  # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                 # pre = [0] + list(accumulate(l))
from decimal import Decimal             # a = Decimal(a)    # use this for math questions
from collections import Counter         # d = dict(Counter(l))
from collections import defaultdict     # d = defaultdict(list)

'''
3
1 1
2 4
3 2
'''

def solve(l):
	n = len(l)
	d = defaultdict(int)
	l1,l2,l3 = [],[],[]
	for x,y in l:
		l1.append(x+y)
		l2.append(x-y)
		l3.append(y-x)
	a = abs(max(l1) - min(l1))
	b = abs(max(l2) - min(l2))
	c = abs(max(l3) - min(l3))
	return max(a,b,c)

N = int(stdin.readline())
L = []
for i in range(N):
	a,b = map(int, input().split())
	L.append([a,b])
ans = solve(L)
print(ans)



Measured memory_bytes: 149232