akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
bool so[50001]={};

int main(){
  so[0] = 1;
  so[1] = 1;
  for(int i=2;i*i<=50000;i++)
    if(so[i]==0)
      for(int j=2;j*i<=50000;j++)
	so[i*j] = 1;
  int n;
  while(cin>>n && n){
    int co=0;
    for(int i=2;i<=n/2;i++)
      if(so[i]==0 && so[n-i]==0) co++;
    cout <<co<<endl;
  }
  return 0;
}

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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n,m,a[2002],b[2002];

struct item{
ll wt,val;};
ll solve(vector<item>v,ll n,ll W){
    ll maxVal=n*1000;
   ll dp[n+1][maxVal+1];
   for(int val=0;val<=maxVal;val++){
    dp[1][val]=INT_MAX;
   }
   dp[1][0]=0;
   dp[1][v[1].val]=v[1].wt;
   for(int i=2;i<=n;i++){
    for(int val=0;val<=maxVal;val++){
        dp[i][val]=dp[i-1][val];
        if(v[i].val>val)continue;
        dp[i][val]=min(dp[i][val],v[i].wt+dp[i-1][val-v[i].val]);
    }
   }
ll ans=0;
for(int x=0;x<=maxVal;x++){
    if(dp[n][x]<=W){
        ans=x;
    }
}
return ans;
}

int main()
{
    FIO;
    ll c,d,e,f=0,sum=0,ans,ck,k,p,q,r,t,add=0,w,x,y,z;
    cin>>n>>w;
    vector<item>v(n+1);

    for(int i=1;i<=n;i++){cin>>v[i].wt;cin>>v[i].val;}
    ck=solve(v,n,w);
    cout<<ck<<endl;





    return 0;
}




Measured memory_bytes: 78336
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int t, x, y;
int main()
{
    int n;
    cin >> n;
    // bool flg = true;
    int _t = 0, _x = 0, _y = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> t >> x >> y;
        int dt = t - _t;
        int dd = abs(x - _x) + abs(y - _y);
        // cout << dt << "," << dd << endl;
        if (dd <= dt && ((dt % 2) == (dd % 2)))
        {
            _x = x;
            _y = y;
            _t = t;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(int i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    REP(i, N)
        cin >> a[i] >> b[i] >> c[i];

    vector<vector<int>> dp(N+1, vector<int>(3));
    REP(i, N){
        dp[i+1][0] = max(dp[i+1][0], max(dp[i][1] + b[i], dp[i][2] + c[i]));
        dp[i+1][1] = max(dp[i+1][1], max(dp[i][2] + c[i], dp[i][0] + a[i]));
        dp[i+1][2] = max(dp[i+1][2], max(dp[i][0] + a[i], dp[i][1] + b[i]));
    }
    int ans = max(dp[N][0], max(dp[N][1], dp[N][2]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int K;
string S;
void input(){
    fast_io();
    cin >> K >> S;
}

string change(string s, int k){
    if(s.length()<=k) return s;
    string ret = s.substr(0,k);
    ret += "...";
    return ret;
}

int solve(){
    cout << change(S,K) << endl;
    return 0;
}   

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

Measured memory_bytes: 3644
/*  -*- coding: utf-8 -*-
 *
 * 2978.cc: Undo Swapping
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

bool rs[MAX_N], cs[MAX_N], used[MAX_N];
int as[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    int ri, ci;
    scanf("%d%d", &ri, &ci);
    ri--, ci--;
    if (rs[ri] || cs[ci]) {
      puts("-1");
      return 0;
    }
    rs[ri] = cs[ci] = true;
    as[ri] = ci;
  }

  int sum = 0;
  for (int st = 0; st < n; st++)
    if (! used[st]) {
      used[st] = true;
      for (int i = as[st]; ! used[i]; sum++, used[i] = true, i = as[i]);
    }

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



Measured memory_bytes: 3888
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = INT_MAX;
using Container = vector<Int>;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

int main() {

	Int x; cin >> x;

	Int tmp = (x / 11);
	Int ans = 2 * tmp;
	if (1 <= x % 11 && x % 11 <= 6)ans++;
	if (x % 11 > 6)ans += 2;

	cout << ans << endl;

}

Measured memory_bytes: 256
A,B,C,X = [int(input()) for _ in range(4)]

answer = 0
for a in range(0,A+1):
  for b in range(0,B+1):
    for c in range(0,C+1):
      x = a*500 + b*100 + c*50
      if X == x:
        answer += 1

print(answer)


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

int main(){

    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    sort(p.rbegin(), p.rend());
    int sum = p[0] / 2;
    for(int i = 1; i < N; i++) sum += p[i];
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c) - max({a, b, c}) << endl;
  return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int N;
    string s,t;
    cin >> N >> s >> t;

    rep(i,N)
    {
        cout << s[i] << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
function Main(input){
  const arr = input.split('\n');
  let data, a, op, b;
  for (let i = 0; i < arr.length; i++){
    data = arr[i].split(' ');
    a = Number(data[0]);
    op = data[1];
    b = Number(data[2]);
    switch (op){
      case '+':
       console.log(a + b);
       break;
      case '-':
       console.log(a - b);
       break;
      case '*':
       console.log(a * b);
       break;
      case '/':
       console.log(Math.floor(a / b));
       break;
      case '?':
       return;
      }
    }
    console.log(data, a, op, b);
  }
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
int ans;
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= 9; i++){
		if(n % i == 0){
			if(n / i <= 9){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

using namespace std;

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

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans += x % 2;

    }

    if (ans % 2 and n != 1) {
        cout << "NO";
    } else {
        cout << "YES";
    }
}


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

int main(){
  int n,m;
  set<string> id;

  cin >> n;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    id.insert(s);
  }

  cin >> m;
  int open = 0;
  for(int i=0;i<m;i++){
    string s;
    cin >> s;
    if(id.count(s) == 0)cout << "Unknown " << s << endl;
    else {
      cout << (open?"Closed":"Opened") <<  " by " << s << endl;
      open = 1-open;
    }
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define mp(a, b) make_pair(a, b)
const int maxn = 1e6 + 10;
pii a[maxn];
vector<pii> b, c;
bool cmp1(const pii & x, const pii & y) { return x.first < y.first;}
bool cmp2(const pii & x, const pii & y) { return x.second > y.second;} 
int main()
{
	int n;
	string s;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		cin >> s;
		for(auto v : s)
		{
			if(v == '(')
				a[i].second++;
			else
			{
				if(a[i].second)
					--a[i].second;
				else
					++a[i].first;
			}
		}
		if(a[i].second >= a[i].first)
			b.push_back(a[i]);
		else 
			c.push_back(a[i]);
	}
	sort(b.begin(), b.end(), cmp1);
	sort(c.begin(), c.end(), cmp2);
	pii cur = mp(0, 0);
	for(auto v : c) b.push_back(v);
	for(auto v : b)
	{
		int e = min(cur.second, v.first);
		cur.second -= e;
		v.first -= e;
		cur.first += v.first;
		cur.second += v.second;
	}
	if(cur.first == 0 && cur.second == 0)
		puts("Yes");
	else
		puts("No");
	return 0;
}
/*
5
(()
(()
)))(
(
)
*/

Measured memory_bytes: 23300
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, M = map(int, input().split())
    AB = []
    CD = []
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append((a,b))

    for _ in range(M):
        c,d = map(int, input().split())
        CD.append((c, d))

    for i in range(N):
        a = AB[i][0]
        b = AB[i][1]
        d_min = INF
        index = 0
        for j, cd in enumerate(CD):
            c = cd[0]
            d = cd[1]
            d = abs(a-c) + abs(b-d)
            if d<d_min:
                d_min = d
                index = j+1
        print(index)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int cnt, m;
int G[100]={1};

void insertionSort(int *A, int n, int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;

    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }

    A[j+g]=v;
  }
}

void shellSort(int *A, int n){
  cnt=0;

  for(int i=1;i<100;i++){
    G[i]=3*G[i-1]+1;
    if(G[i]>n){
      m=i;
      break;
    }
  }

  for(int i=0;i<m;i++){
    insertionSort(A, n, G[m-i-1]);
  }
}

int main(){

  int n, a[1000000];

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

  shellSort(a, n);

  printf("%d\n", m);

  for(int i=0;i<m;i++){
    printf("%s", (i?" ":""));
    printf("%d", G[m-i-1]);
  }
  printf("\n");

  printf("%d\n", cnt);

  for(int i=0;i<n;i++) printf("%d\n", a[i]);

  return 0;
}



Measured memory_bytes: 7120
#include<stdlib.h>
#include<cstdio>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<map>
#include<string.h>
#include<iostream>
#include<queue>
using namespace std;

signed main() {
	vector<int>O;
	O.push_back(1); O.push_back(2); O.push_back(3);
	int a, b;
	while (cin >> a >> b, a | b) {
		int sum[2]{}; int S = 0;
		vector<int>V[3];
		for (int i = 0; i < 3; i++) {
			int d; cin >> d;
			for (int e = 0; e < d; e++) {
				int c; cin >> c;
				V[i].push_back(c);
			}
		}
		int x = 0, y = 0;//???????????????
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				vector<int>q = V[0], w = V[1], p = V[2];
				if (abs(i - j) == 1) {
					if (V[i].size() && (V[j].size() == 0 || *V[i].rbegin() > *V[j].rbegin())) {
						V[j].push_back(*V[i].rbegin());
						V[i].pop_back();
						x = i; y = j;
						sum[S]++;
						for (int K = 0; K <= b; K++) {
							if (V[1].size() == 0 && (V[0].size() == 0 || V[2].size() == 0))break;
							sum[S]++;
							for (int i = 0; i < 3; i++) {
								for (int j = 0; j < 3; j++) {
									if (abs(i - j) == 1) {
										if (V[i].size() && (V[j].size() == 0 || *V[i].rbegin() > *V[j].rbegin())) {
											if (y != i || x != j) {
												V[j].push_back(*V[i].rbegin());
												V[i].pop_back();
												x = i; y = j;
												goto l;
											}
										}
									}
								}
							}
						l:;
							if (K == b)sum[S] = 1 << 29;
						}
						S++;
					}
				}
				V[0] = q; V[1] = w; V[2] = p;
			}
		}
		int MIN = min(sum[0], sum[1]);
		if (MIN == 1 << 29)puts("-1");
		else cout << MIN << endl;
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	ll n;
	cin >> n;
	
	ll ks =1;
	string s;
	while( n != 0){
		if(n%(abs(2*ks))){ s ='1'+s; n -=ks;}
		else s = '0'+s;
		ks *= -2;
	}
	if(!sz(s)) s="0";
	cout <<s <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pp;
typedef vector<int> vec;
typedef vector<vec> mat;
mat path,path2;

int N,M,C;
const int MAX_N = 10005;
const int MAX_M = 100005;

pp a[MAX_N*2];
int rev[MAX_N*2],init_sz[MAX_M*2],init_sz2[MAX_M*2];
int s[MAX_M*2],sz;
bool vsi[MAX_M*2],isFirst;
int color[MAX_M*2];
void push_edge(int x,int y){
    path[x].push_back(y);
    path2[y].push_back(x);
}

void push_edge(int x,int L,int R){
    x+=C;
    L+=C;
    R+=C;
    while(L<R){
        if(L%2==1){
            push_edge(x,L+M);
            push_edge(L,x+M);
            L++;
        }
        if(R%2==0){
            push_edge(x,R+M);
            push_edge(R,x+M);
            R--;
        }
        L>>=1,R>>=1;
    }
    if(L==R){
        push_edge(x,L+M);
        push_edge(L,x+M);
    }
}

void dfs(int v){
    vsi[v] = 1;
    for(int u:path[v]){
        if(vsi[u])continue;
        dfs(u);
    }
    s[sz++]=v;
}

void dfs2(int v,int T){
    vsi[v] = 0;
    color[v] = T;
    for(int u:path2[v]){
        if(vsi[u]==0)continue;
        dfs2(u,T);
    }
}

void init(int d){
    if(isFirst){
        isFirst = false;
        path.assign(2*M,vec());
        path2.assign(2*M,vec());

        for(int i=0;i<N;i++){
            if(a[i].second%2)continue;
            int x = i+C;
            int y = rev[a[i].second+1]+C;
            push_edge(x,y+M);
            push_edge(x+M,y);
            push_edge(y,x+M);
            push_edge(y+M,x);
        }

        for(int i=1;i<C;i++){
            if(i*2<M)push_edge(i*2,i);
            if(i*2+1<M)push_edge(i*2+1,i);
            if(i*2<M)push_edge(i+M,i*2+M);
            if(i*2+1<M)push_edge(i+M,i*2+1+M);
        }
        
        for(int i=0;i<2*M;i++){
            init_sz[i] = path[i].size();
            init_sz2[i] = path2[i].size();
        }
    }else{
        for(int i=0;i<2*M;i++){
            path[i].resize(init_sz[i]);
            path2[i].resize(init_sz2[i]);
        }
    }

    int L=0,R=0;
    for(int i=0;i<N;i++){
        while(a[i].first-a[L].first>=d)L++;
        while(R<N&&a[R].first-a[i].first<d)R++;
        push_edge(i,L,i-1);
        push_edge(i,i+1,R-1);
    }
}

bool chk(int d){
    init(d);
    
    for(int i=0;i<2*M;i++){
        if(vsi[i]==0){
            dfs(i);
        }
    }

    int T=0;
    while(sz>0){
        int v = s[sz-1];
        if(vsi[v]){
            dfs2(v,T++);
        }
        sz--;
    }

    for(int i=0;i<M;i++){
        if(color[i] == color[i+M])return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);

    cin>>N;
    N = N*2;
    for(C=1;C<N;C<<=1);
    M = C+N;
    for(int i=0;i<N;i++){
        cin>>a[i].first;
        a[i].second = i;
    }
    sort(a,a+N);
    for(int i=0;i<N;i++){
        rev[a[i].second] = i;
    }
    isFirst = true;

    int lo=0,hi=1e9,mid;
    while(lo+1<hi){
        mid = (lo+hi)/2;
        if(chk(mid)){
            lo = mid;
        }else{
            hi = mid;
        }
    }
    cout<<lo<<endl;
}


Measured memory_bytes: 37888
#%%
n = int(input())
a = list(map(int,input().split()))

s = sum(a) / len(a)

ans = 0
tmp = 10**9

for i in range(n):
    if tmp > abs(s-a[i]):
        ans = i
        tmp = abs(s-a[i])

print(ans)


#%%


Measured memory_bytes: 3060
using System;
using System.IO;
using System.Collections.Generic;

namespace ARC091
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(Long);
            var K = ss.Next(Long);

            if (K == 0)
            {
                sw.WriteLine(N * N);
                return;
            }
            
            var ans = 0L;
            for (var i = 0; i < N; i++)
            {
                ans += Math.Max(0, N / (i + 1) * (i - K + 1));
                ans += Math.Max(0, N % (i + 1) - K + 1);
            }

            sw.WriteLine(ans);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

// const ll MOD=1000000007ll;
const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll fact[364364], fact_inv[364364];

ll mod_pow(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1){
			res=FIX(res*a);
		}
		a=FIX(a*a);
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return FIX(FIX(fact[n]*fact_inv[r])*fact_inv[n-r]);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	ll k;
	cin>>n>>a>>b>>k;
	fact[0]=1;
	REP(i, n){
		fact[i+1]=FIX(fact[i]*(i+1));
	}
	fact_inv[n]=mod_pow(fact[n], MOD-2);
	FORR(i, 0, n){
		fact_inv[i]=FIX(fact_inv[i+1]*(i+1));
	}
	ll ans=0;
	REP(i, n+1){
		if((k-i*a)%b==0){
			int j=(k-i*a)/b;
			if(j>=0 && j<=n){
				ans=FIX(ans+FIX(comb(n, i)*comb(n, j)));
				// DEBUG(i);
				// DEBUG(comb(n, i));
				// DEBUG(j);
				// DEBUG(comb(n, j));
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n, 0);
  for(int i = 0; i < n; ++i){
    cin >> v[i];
  }
  long long sum = 0;
  int now = v[0];
  for(int i = 1; i < n; ++i){
    if(now > v[i]){
      sum += now - v[i];
    }
    else {
      now = v[i];
    }
  }
  cout << sum << endl;
}

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

int main(void)
{
    int a,b;

    cin >> a >> b;

    if(a==1) a = 14;
    if(b==1) b = 14;
    if(a > b) cout << "Alice" <<endl;
    else if(b > a) cout << "Bob" <<endl;
    else cout << "Draw" <<endl;
    return 0;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc110/submissions/3249843

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
  int n, m, x, y;
  int a[105];
  int b[105];

  cin >> n >> m >> x >> y;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }

  sort(a, a+n);
  reverse(a, a+n);
  sort(b, b+m);
  for(int z = x+1; z <= y; z++){
    if(a[0] < z && b[0] >= z){
      cout << "No War" << endl;
      return 0;
    }
    // cout << "a[0]:" << a[0] << " b[0]:" << b[0] << " z:" << z << endl;
  }
  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int n,k,x,y;
	
	int f=0;
	int l=0;
	
	cin>>n>>k>>x>>y;
	
	f=k*x;
	l=(n-k)*y;
	if(n<k){
	cout<<n*x<<endl;
	}else{
	cout<<f+l<<endl;
	}
return 0;

}



Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
def run_length_encode(s):
    count = 1
    code = []
    target = s[0]
    for i in range(1, len(s)):
        if target == s[i]: count += 1
        else:
            code.append((target, count))
            target = s[i]
            count = 1
    code.append((target, count))
    return code

N = iin()
h = iln()

dp = [10**9] * (N)
dp[0] = 0

for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
    if i-2 >= 0:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])



Measured memory_bytes: 16592
N = gets.to_i
W = (?a..?j).to_a

def solve(word, i)
  if word.size == N
    puts word
    return
  end
  0.upto(i+1) do |j|
    solve(word + W[j], [i,j].max)
  end
end

solve(?a, 0)


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;

long long  N,K;
int main(){
    cin >> N >> K;
    vector<long long> n(K);
    for(int i = 1; i <= N;++i) ++n[i%K];
    long long ans = 0;
    for(int a=0;a<K;++a){
        // (a+b) % K == 0 -> b = -a (mod K)
        int b = (K - a) % K;
        int c = (K - a) % K;
        if((b+c)%K == 0) ans += n[a]*n[b]*n[c];
    }
    cout << ans << endl;
}

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

int n;
string name[100];
int price[100];
int m;
string o[100];
int k[100];
string q[100][100];

int minprice(string item){
  int i,j;
  int tmp,min,flag;;

  for(i=0;i<n;i++){
    if(name[i] == item)min = price[i];
  }

  tmp = 0;
  flag = 0;
  for(i=0;i<m;i++){
    if(o[i] == item){
      flag = 1;
      for(j=0;j<k[i];j++){
	tmp += minprice(q[i][j]);
      }
    }
  }
  
  if(flag && min>tmp)return tmp;
  else return min;
}

int main(){
  int i,j;
  string item;

  while(1){
    cin >> n;
    if(!n)break;

    for(i=0;i<n;i++)cin >> name[i] >> price[i];

    cin >> m;
    for(i=0;i<m;i++){
      cin >> o[i] >> k[i];
      for(j=0;j<k[i];j++)cin >> q[i][j];
    }
    cin >> item;

    cout << minprice(item) <<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


signed main() {
  int H, W;

  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  int cnt = 0;
  rep(i, H) {
    rep(j, W) {
      cin >> A[i][j];
      cnt += (A[i][j] == '#');
    }
  }
  if (cnt == H + W - 1)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
	int t = 0, d, r;
	double x, y;
	x = y = 0.0;
	for(; scanf("%d,%d",&r,&d),r|d;){
		y += r * cos( t /57.3 );
		x -= r * sin( t /57.3 );
		t -= d;
	}
	return!printf("%d\n%d\n",t=x,d=y);
}

Measured memory_bytes: 0
//set many funcs template
//Ver.20190820
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<assert.h>
#include<math.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}

int main(void){
  int i,j,n,m,k,a,b,c,h,w,r=0,l,t;
  double d=0.0,x[16],y[16];
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%lf%lf",&x[i],&y[i]);}
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      d+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  printf("%.12lf\n",d*((double)fact(n-1))/((double)fact(n)));
  return 0;
}


Measured memory_bytes: 128
A = 3.times.map { gets.split.map(&:to_i) }
N = gets.to_i
B = N.times.map { gets.to_i }

def check(n)
  3.times do |i|
    3.times do |j|
      if A[i][j] == n
        A[i][j] = -1
      end
    end
  end
end

B.each do |b|
  check(b)
end

def bingo?
  return true if [A[0][0], A[0][1], A[0][2]].all? { |x| x == -1 }
  return true if [A[1][0], A[1][1], A[1][2]].all? { |x| x == -1 }
  return true if [A[2][0], A[2][1], A[2][2]].all? { |x| x == -1 }
  return true if [A[0][0], A[1][0], A[2][0]].all? { |x| x == -1 }
  return true if [A[0][1], A[1][1], A[2][1]].all? { |x| x == -1 }
  return true if [A[0][2], A[1][2], A[2][2]].all? { |x| x == -1 }
  return true if [A[0][0], A[1][1], A[2][2]].all? { |x| x == -1 }
  return true if [A[0][2], A[1][1], A[2][0]].all? { |x| x == -1 }
  false
end

if bingo?
  puts 'Yes'
else
  puts 'No'
end


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

public class P
{
    public int d { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new List<int>[n + 1];
        for (int i = 1; i <= n; i++) d[i] = new List<int>();
        var dn = new string[n + 1];
        Console.ReadLine();
        dn[1] = Console.ReadLine().Trim();
        for (int i = 2; i <= n; i++)
        {
            var k = int.Parse(Console.ReadLine().Trim());
            var m = Console.ReadLine().Trim();
            dn[i] = m;
            d[k].Add(i);
        }
        print(d, dn);
    }
    static void print(List<int>[] d, string[] dn)
    {
        var sb = new StringBuilder();
        var st = new Stack<P>();
        st.Push(new P { d = 0, id = 1 });
        while (st.Count() > 0)
        {
            var w = st.Pop();
            sb.Append(new string('.', w.d));
            sb.Append(dn[w.id]);
            sb.Append("\n");
            var dc = d[w.id].Count();
            if (dc > 0)
            {
                d[w.id].Reverse();
                foreach (var x in d[w.id])
                    st.Push(new P { d = w.d + 1, id = x });
            }
        }
        Console.Write(sb);
    }
}


Measured memory_bytes: 20648
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int cnt = 0;
        boolean flg = false;
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == b){
                cnt++;
            }else{
                cnt = 0;
            }
            if(cnt >= 3){
                flg = true;
            }
        }
        pw.println(flg ? "Yes" : "No");
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    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: 25608
from math import inf
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
def dist(x,y,k):
    if k == inf:
        d = 0
        for i in range(n):
            tmp = abs(x[i] - y[i])
            if tmp > d:
                d = tmp
        return d
    d = 0
    for i in range(n):
        d += (abs(x[i] - y[i]))**k
    return d**(1/k)
print(dist(x,y,1))
print(dist(x,y,2))
print(dist(x,y,3))
print(dist(x,y,inf))



Measured memory_bytes: 5696
#include <iostream>
#include <stdio.h>
#include<vector>
#include<map>
#include <algorithm>

using namespace std;

unsigned int getPow2(unsigned int num) { //i以上で最小の2のべき乗数を返す
    int i = 0;
    while(1) {
        num >>= 1;
        if(num <= 0) break;
        i++;
    }
    return 1 << i+1;
}

int main(int, char**) {
    unsigned int N, A;
    map<unsigned int, unsigned int> A_map; //値,個数
    vector<unsigned int> A_vector;
    unsigned int max_odd_index = 0, max_even_index = 0;
    int num_pow2 = 0;
    cin >> N;
    // A_vector.reserve(N);
    for(int i = 0; i< N ; i++) {
        cin >> A;
        A_map[A]++;
        A_vector.push_back(A);
    }
    sort(A_vector.begin(), A_vector.end(), greater<int>());
    //ペア探し
    for(int i = 0; i < N; i++) {
        if(A_map[A_vector[i]]==0) continue;
        A_map[A_vector[i]]--;
        if (A_map[getPow2(A_vector[i])-A_vector[i]]!=0) {
            A_map[getPow2(A_vector[i])-A_vector[i]]--;
            num_pow2++;
        }
    }
    cout << num_pow2 << endl;
    return 0;
}

Measured memory_bytes: 19828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		char[][] A = new char[N][N];
		char[][] B = new char[N][N];
		for (int i = 0; i < N; i++) {
			String s = in.next();
			A[i] = s.toCharArray();
		}
		for (int i = 0; i < M; i++) {
			String s = in.next();
			B[i] = s.toCharArray();
		}
		String ans = "No";
		for (int i = 0; M <= (N - i); i++) {
			boolean isOk = true;
			for (int j = 0; j < M; j++) {
				for (int j2 = 0; j2 < M; j2++) {
					if (A[j][i + j2] != B[j][j2]) {
						isOk = false;
						break;
					}
				}
				if (!isOk) {
					break;
				}
			}
			if (isOk) {
				ans = "Yes";
				break;
			}
		}
		for (int i = 0; M <= (N - i); i++) {
			boolean isOk = true;
			for (int j = 0; j < M; j++) {
				for (int j2 = 0; j2 < M; j2++) {
					if (A[i + j][j2] != B[j][j2]) {
						isOk = false;
						break;
					}
				}
				if (!isOk) {
					break;
				}
			}
			if (isOk) {
				ans = "Yes";
				break;
			}
		}
		for (int i = 0; M <= (N - i); i++) {
			boolean isOk = true;
			for (int j = 0; j < M; j++) {
				for (int j2 = 0; j2 < M; j2++) {
					if (A[i + j][i + j2] != B[j][j2]) {
						isOk = false;
						break;
					}
				}
				if (!isOk) {
					break;
				}
			}
			if (isOk) {
				ans = "Yes";
				break;
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 23892
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N >> M;
	vector< vector< int > > G(N, vector< int >(N, INT_MAX / 2));
	edges es(M);
	rep(i, M) {
		int A, B, C;
		cin >> A >> B >> C;
		--A;
		--B;
		G[A][B] = G[B][A] = C;
		es[i] = edge(A, B, C);
	}
	rep(k, N) rep(i, N) rep(j, N) chmin(G[i][j], G[i][k] + G[k][j]);
	int ans = 0;
	rep(i, M) {
		edge e = es[i];
		if (G[e.from][e.to] < e.d)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        int res = 0;// 条件を満たすx,y,zの値の組み合わせ数
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - (x + y);
                if (z < 0 || z > k) continue;// zが範囲外のため次のループへ

                res++;
            }
        }

        System.out.println(res);
    }


}


Measured memory_bytes: 21712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    int ans = INT_MAX;
    for (int same = -100; same <= 100; same++)
    {
        int sum = 0;
        rep(i,n) {
            sum += (a[i]-same)*(a[i]-same);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define ll long long
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define bug cout << "ok" << endl

const ll INF = 1e9 + 5, N = 1e3 + 5, mod = 1e9 + 7, M = 1e6 + 5;

char a[N][N];

int main(){
	speed;
	int n, m;
	cin >> n >> m;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int d[N][N];
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[i][j];
			d[i][j] = INF;
		}
	}	
	set <pair <int, pair <int, int> > > q;
	d[x1][y1] = 0;
	q.insert({0, {x1, y1}});
	while(q.size()){
		int v1 = q.begin() -> second.first, v2 = q.begin() -> second.second;
		q.erase(q.begin());
		for(int i = -1; i <= 1; i++){
			for(int j = -1; j <= 1; j++){
				if(i != 0 && j != 0) continue;
				if(v1 + i < 1 || v1 + i > n || v2 + j < 1 || v2 + j > m) continue;
				if(a[v1 + i][v2 + j] == '#') continue;
				if(d[v1][v2] < d[v1 + i][v2 + j]){
					q.erase({d[v1 + i][v2 + j], {v1 + i, v2 + j}});
					d[v1 + i][v2 + j] = d[v1][v2];
					q.insert({d[v1 + i][v2 + j], {v1 + i, v2 + j}}); 
				}
			}
		}
		for(int i = -2; i <= 2; i++){
			for(int j = -2; j <= 2; j++){
				if(v1 + i < 1 || v1 + i > n || v2 + j < 1 || v2 + j > m) continue;
				if(a[v1 + i][v2 + j] == '#') continue;
				if(d[v1][v2] + 1 < d[v1 + i][v2 + j]){
					q.erase({d[v1 + i][v2 + j], {v1 + i, v2 + j}});
					d[v1 + i][v2 + j] = d[v1][v2] + 1;  
					q.insert({d[v1 + i][v2 + j], {v1 + i, v2 + j}}); 
				}
			}
		}
	}
	if(d[x2][y2] == INF) d[x2][y2] = -1;
	cout << d[x2][y2] << endl;
}

Measured memory_bytes: 8712
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <list>

using namespace std;

void swap(int& a, int& b) {
	int perm = a;
	a = b;
	b = perm;
}

int main()
{
	ios_base::sync_with_stdio(false);

	int a, b, c;
	cin >> a >> b >> c;

	swap(a, b);
	swap(a, c);

	cout << a << " " << b << " " << c << " ";



	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
	FAST_IO
	
	int N, best = -INF; cin >> N;
	vector<int> shops(N);
	vector<vector<int>> profit(N, vector<int>(15));
	
	auto getBinary = [&](int a){
		for(int pos = 9; pos >= 0; --pos) cout << ((a & (1 << pos)) ? 1 : 0) << " ";
		cout << endl;
	};
	
	auto getInt = [&](int a, int b){
		int count = 0;
		for(int pos = 0; pos < 10; ++pos){
			if((a & (1 << pos)) && (b & (1 << pos))) count++;
		}
		
		return count;
	};
	
	for(int rep = 0; rep < N; ++rep){
		int &ele = shops[rep];
		for(int pos = 0; pos < 10; ++pos){
			int open; cin >> open;
			ele |= (open << pos);
		}
	}
	
	for(int s = 0; s < N; ++s){
		for(int clash = 0; clash <= 10; ++clash){
			cin >> profit[s][clash];
		}
	}
	

	
	for(int mask = 1; mask < (1 << 10); ++mask){
		int cur = 0;
		
		for(int s = 0; s < N; ++s){
			int inter = getInt(shops[s], mask);
			cur += profit[s][inter];
		}

		max_self(best, cur);
	}
			
	cout << best << "\n";
			
	return 0;
}


Measured memory_bytes: 256