akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n,m;
  cin>>n>>m;
  cout<<(100*(n-m)+1900*m)*pow(2,m)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
    int n,a,s=0,k=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        
        if(a==0){
            k=0;
        }
        if(a==1){
            k=k+1;
        }
        if(k>s){
            s=k;
        }
        
        
    }
    cout<<s+1<<endl;
   
    return 0;
}


Measured memory_bytes: 3112
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,w = LI()
    cy,cx = LI()
    gy,gx = LI()
    s = [input() for _ in range(h)]
    cy -= 1
    cx -= 1
    gy -= 1
    gx -= 1
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    bfs = [[float("inf")]*w for i in range(h)]#コスト
    bfs[cy][cx] = 0
    q = deque([(cy,cx)])
    while q:
        y,x = q.popleft()
        b = bfs[y][x]
        if (y,x) == (gy,gx):
            print(b)
            return
        for dy,dx in d:
            ny,nx = y+dy,x+dx
            if 0 <= ny < h and 0 <= nx < w and s[ny][nx] != "#" and b < bfs[ny][nx]:
                bfs[ny][nx] = b
                q.appendleft((ny,nx))
        nb = b+1
        for dy in range(-2,3):
            for dx in range(-2,3):
                ny,nx = y+dy,x+dx
                if 0 <= ny < h and 0 <= nx < w and s[ny][nx] != "#" and nb < bfs[ny][nx]:
                    bfs[ny][nx] = nb
                    q.append((ny,nx))
    print(-1)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 104360
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, a[100009], b[100009], p[100009]; long long K;
bool compare(int i, int j) {
	return a[i] < a[j];
}
int main() {
	scanf("%d %lld", &N, &K);
	for (int i = 0; i < N; i++) scanf("%d %d", &a[i], &b[i]), p[i] = i;
	sort(p, p + N, compare);
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		sum += b[p[i]];
		if (sum >= K) {
			printf("%d\n", a[p[i]]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
S=list(input())
l=[]
for i in range(len(S)):
    if (i+2)%2==0:
        l.append(0)
    else:
        l.append(1)
for i in range(len(S)):
    l[i]=abs(int(S[i])-l[i])
print(min(sum(l),len(S)-sum(l)))

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

int main()
{
    int n, x;
    cin >> n >> x;
    vector <int> v(n);
    for (auto & i : v)
        cin >> i;
    sort(v.begin(), v.end());
    int ans = 0;
    for (auto i : v)
        if (i <= x)
            ans++, x -= i;
    if (ans == n && x != 0)
        ans--;
    cout << ans << '\n';
    return 0;
}


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

using namespace std;
#define BUF (1000)
#define ll long long 

int n;
int c[4][4];

int check(int r1,int r2,int l1, int l2){
	if(c[r1][l1]+c[r2][l2]==c[r1][l2]+c[r2][l1]) return 1;
	
	return 0;
}

int f=0;
int main(void){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin >> c[i][j];
		}
	}

	if(check(1,2,1,2)==0) f=1;
	if(check(1,2,1,3)==0) f=1;
	if(check(1,2,2,3)==0) f=1;
	if(check(1,3,1,2)==0) f=1;
	if(check(1,3,1,3)==0) f=1;
	if(check(1,3,2,3)==0) f=1;
	if(check(1,2,1,2)==0) f=1;
	if(check(1,2,1,3)==0) f=1;
	if(check(1,2,2,3)==0) f=1;

	if(f==1){
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(){
  int N;
  scanf("%d",&N);
  
  char song[N][101];
  int sec[N];
  int i;
  
  for(i=0;i<N;i++){
    scanf("%s %d",&song[i],&sec[i]);
  }
  
  
  char str1[101];
  scanf("%s",str1);
  
  int count = 0;
  
  for(i=0;i<N;i++){
    if(strcmp(song[i],str1)==0){
      count++;
      break;
    }
    
    count++;
  }
  
  int sum = 0;
  
  for(i=count;i<N;i++){
    sum += sec[i];
  }
  
  printf("%d",sum);
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        //int b = sc.nextInt();
        //int c = sc.nextInt();
        //String s = sc.next();
 
/*        if(N%2 != 0){
        for(int i = 1; i <= N; i++){
            for(int j = i; j <= N; j++){
                c = i*j;
                if(c == N){
                    d = i+j-2;
                    if(min == 0 || min > d) min = d;
            }
        }
    }
}*/
double R = (double)r * Math.PI * 2;
    System.out.println(R);
    }
    }

Measured memory_bytes: 36076
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int larger(int x, int y){
	if(x > y){
		return x;
	}
	else{
		return y;
	}
}

int main(){
	int N, W;
	cin >> N >> W;
	int values[N];
	int weight[N];
	for(int i = 0; i < N; i++){
		cin >> values[i] >> weight[i];
	}
	int dp[N+1][W+1];
	for(int i = 0; i < N+1; i++){
		for(int j = 0; j < W+1; j++){
			dp[i][j] = 0;
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < W+1; j++){
			if(j < weight[i]){
				dp[i+1][j] = dp[i][j];
			}
			else{
				dp[i+1][j] = larger(dp[i][j-weight[i]]+values[i], dp[i][j]);
			}
		}
	}
	cout << dp[N][W] << "\n";
}



Measured memory_bytes: 7056
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

typedef unsigned long long int ll;

int main() {
    int n, q; cin >> n;
    vector<int> as(n, 0);
    vector<int> mem(200000, 0);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        mem[as[i]]++;
        ans += as[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        int b, c; cin >> b >> c;
        ans = ans - (b * mem[b]) + (c * mem[b]);
        mem[c] += mem[b];
        mem[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int ans = T.size();
  
      for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
  
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int i,j=1,n,ans=0,a[200020]={};
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(i=0; i<n; i++){
        if(a[i]==j)j++;
        else ans++;
    }
    if(ans==n){
        printf("-1");
        return 0;
    }
    printf("%d",ans);
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i,N) cin >> a[i];
  sort(a,a+N,greater<int>());
  int alice = 0, bob = 0;
  rep(i,N){
    if(i % 2 == 0) alice+= a[i];
    else            bob += a[i];
  }
  cout << alice - bob << endl;
  return 0;
}


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

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 K;
	cin >> K;
	map<int64, int64> mp;
	int64 now = 7, res = 1;
	while (now % K != 0) {
	  if (now == -1) now = 0;
	  res++;
	  now = now * 10 + 7;
	  now %= K;
	  if (mp.count(now)) {
	    res = -1;
	    break;
	  }
	  mp[now] = res;
	}
	cout << res << endl;
}


Measured memory_bytes: 66112
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int D, N;
    cin >> D >> N;
    if (N != 100)
    {
        cout << static_cast<int>(N * pow(100, D)) << endl;
    }
    else
    {
        cout << static_cast<int>((N + 1) * pow(100, D)) << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
 
#define VV(T) vector<vector< T > >
 
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  reep(i,0,n)
#define clr(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define PB push_back

const int INF = (1e9);
const ll MOD = 1e9+7;
const double EPS = 1e-5;
const double PI=atan2(0,-1);



int main(void){
    int n;
    string s;
    vint cnt = vint(26);
    rep(i,26){
        cnt[i] = INF;
    }
    cin >> n;
    rep(i,n){
        cin >> s;
        vint temp = vint(26);
        rep(i,s.size()){
            temp[(int)(s[i]-'a')]++;
        }
        rep(i,26){
            if(cnt[i] > temp[i]){
                cnt[i] = temp[i];
            }
        }
    }
    int sum=0;
    rep(i,26){
        rep(j,cnt[i]){
            cout << (char)('a' + i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int cnt{};
  while(a >= b) {
    b *= 2;
    cnt++;
  }
  while(b >= c) {
    c *= 2;
    cnt++;
  }
  cout << (cnt <= k ? "Yes" : "No" ) << endl;
}

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

using namespace std;

int main(){
  int n; cin >> n;
  int k; cin >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  
  int dp[n+1]; memset(dp, 0, sizeof(dp));

  if (k > n) k = n;
    int i = 0;
  for (i = 0 ; i < k; i++){
      dp[i] = abs(arr[i] - arr[0]);
  }
      vector<int> num;
  for (; i < n; i++){
      num.clear();
      for (int j = 1; j <= k ; j++){
        int a = dp[i-j] + abs(arr[i-j] - arr[i]);
        num.push_back(a);
      }
    dp[i] = *min_element(num.begin(), num.end());
  }
  
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
ship = [list(map(int, input().split())) for i in range(M)]


goal_ship = set()
transit = set()

for i in ship:
    if i[1] == N:
        goal_ship.add(i[0])
for i in ship:
    if i[0] == 1:
        transit.add(i[1])

ans = goal_ship & transit

if len(ans):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 59532
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

struct card{
	char suit;
	int value;
};

void BubbleSort(vector<card> &a, int n){
	for (int i = 0; i < n; i++){
		for (int j = n - 1; j >= i + 1; j--){
			if (a[j].value < a[j - 1].value) swap(a[j], a[j - 1]);
		}
	}
}

void SelectionSort(vector<card> &a, int n){
	int minj;
	for (int i = 0; i < n; i++){
		minj = i;
		for (int j = i; j < n; j++){
			if (a[j].value < a[minj].value) minj = j;
		}
		if (i != minj) swap(a[i], a[minj]);;
	}
}

int main(){
	int n;
	string s;
	cin >> n;
	vector<vector<char> > s_cheak(14), s_testb(14), s_tests(14);
	vector<card> a(n), b(n);
	for (int i = 0; i < n; i++){
		cin >> s;
		a[i].suit = s[0];
		a[i].value = s[1] - '0';
		b[i] = a[i];
		s_cheak[s[1] - '0'].push_back(s[0]);
	}
	BubbleSort(a, n);
	for (int i = 0; i < n; i++){
		cout << a[i].suit << a[i].value;
		s_testb[a[i].value].push_back(a[i].suit);
		if (i != n - 1) cout << " ";
	}
	cout << endl;
	if (s_cheak == s_testb) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	SelectionSort(b, n);
	for (int i = 0; i < n; i++){
		cout << b[i].suit << b[i].value;
		s_tests[b[i].value].push_back(b[i].suit);
		if (i != n - 1) cout << " ";
	}
	cout << endl;
	if (s_cheak == s_tests) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> v;
  load(v, 2 * n);

  sort(v);
  int sum = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    sum += min(v[i], v[i + 1]);
  }
  p(sum);
}

Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

map<int , vector<pii>> v ;


void solve()
{
    int n , x , d;
    cin >> n >> x >> d;
    if(d < 0){
        x += (n - 1) * d ; 
        d *= -1LL;
    }else if(d == 0){
        if(x == 0){
            cout << 1; 
        }else{
            cout << n + 1 ;
        }
        return ;
    }
    for(int k = 0 ; k <= n ; ++k){
        int rem = ((k * x) % d + d) % d; 
        int l = (k * x - rem) / d + k * (k - 1) / 2; 
        int r = (k * x - rem) / d + (n - 1 + n - k) * k / 2 ; 
        v[rem].pb(mp(l , r));
    }

    int res = 0 ;
    trav(x , v){
        sort(all(x.ss));
        int r = -inf ;
        int ans = 0 ;
        trav(p , x.ss){
            // cout << p.ff << ',' << p.ss << ' ' ;
            if(r == -inf){
                int tmp = (p.ss - p.ff + 1);
                ans += tmp ;
                r = p.ss ;
            }
            else if(p.ff <= r){
                int tmp = (max(r , p.ss) - r);
                ans += tmp ;
                r = max(r , p.ss);
            }else{
                int tmp = (p.ss - p.ff + 1);
                ans += tmp ;
                r = max(r , p.ss);
            }
        }
        // cout << '\n';
        res += ans; 
    }
    cout << res  ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;
using Graph = vector<vector<int>>;

int main(){
    int n,m;
    cin>>n>>m;
    Graph g(n);//vector<vector<int>>g(n);//,vector<int>());
    vector<int> dist(n, -1);
    queue<int> que;
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : g[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    rep(i,0,n){
        if(dist.at(i)==-1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,1,n){
        for(auto p:g.at(i)){
            if(dist.at(p)==dist.at(i)-1){
                cout<<p+1<<endl;
                break;
            }
        }
    }
return 0;
}

Measured memory_bytes: 10288
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int N,M,A,B,C,D,x1,x2,y1,y2;
int K[32][32];
const int inf = 1001001001;

void show(int K[32][32], int N){
  for(int r=1;r<M+1;r++){
    for(int c=1; c<M+1;c++){
      cout << K[r][c] << " ";
    }
    cout << endl;
  }
}

void init_k(int K[32][32]){
  fill(&K[0][0], &K[0][0]+32*32,inf); //Kツづ個渉可甘コツ可サ
}

void senni_k(int K[32][32]){
  K[A][B] = C;
  K[B][A] = D;
}

void Floyd_Warshall(int K[32][32]){
  int i, j, k;
  for(k=1; k<M+1; k++){
    for(i=1; i<M+1; i++){
      for(j=1; j<M+1; j++){
	if(K[i][j] > K[i][k] + K[k][j]){
	  K[i][j] = K[i][k] + K[k][j];
	}
      }
    }
  }
}


int main(){
  int Reward;
  init_k(K);
  scanf("%d %d", &M, &N);
  for(int i=0; i<N; i++){
    scanf("%d,%d,%d,%d", &A, &B, &C, &D);
    senni_k(K);
    //cerr << "read" << A << ' ' << B << ' ' << C << ' ' << D << endl;
  }
  //show(K, M);
  Floyd_Warshall(K);
  //show(K, M);
  scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
  
  Reward = y1 - y2- K[x1][x2] - K[x2][x1];
  cout << Reward << endl;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    d=[[INF]*N for _ in range(N)]
    for _ in range(M):
        a,b,c=map(int1,input().split())
        c+=1
        d[a][b]=c
        d[b][a]=c
    d2=[d[i][:] for i in range(N)]
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d2[i][j]=min(d2[i][j],d2[i][k]+d2[k][j])
    ans=0
    for i in range(N):
        for j in range(N):
            if d[i][j]!=INF and d[i][j]!=d2[i][j]:
                ans+=1
    print(ans//2)

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    long long n, m;
    cin >> n >> m;
    
    long long ans = -1;
    for (long long i = 1; i * i <= m; i++){
        if (m % i != 0) continue;
        long long temp = m / i;
        if (n * i <= m) ans = max(ans, i);
        if (n * temp <= m) ans = max(ans,temp);
    }
    cout << ans << endl;
}

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

string s, res;
int main()
{
    cin >> s;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '0')
            res += '0';
        else if(s[i] == '1')
            res += '1';
        else
        {
            if(res.size())
                res = res.erase(res.size()-1);
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
length = arr.length
answer = []
boxes = Array.new(length, 0)
arr.length.downto(1) do |i|
  sum = 0
  2.upto((length / i)) do |j|
    sum += boxes[(j * i) - 1]
  end
  judge = sum % 2 != arr[i - 1]
  boxes[i - 1] = judge ? 1 : 0
  if judge
    answer << i
  end
end

puts answer.length
puts answer.join(' ') if answer.length > 0


Measured memory_bytes: 22460
s=input()
ans=0
ls=len(s)
if ls%2==1:
    if s[ls//2]=="i" or s[ls//2]=="w":pass
    else:ans+=1
    for i in range(ls//2):
        if s[i]=="i":
            if s[ls-i-1]!="i":ans+=1
        elif s[i]=="w":
            if s[ls-i-1]!="w":ans+=1
        elif s[i]=="(":
            if s[ls-i-1]!=")":ans+=1
        elif s[i]==")":
            if s[ls-i-1]!="(":ans+=1
else:
    for i in range(ls//2):
        if s[i]=="i":
            if s[ls-i-1]!="i":ans+=1
        elif s[i]=="w":
            if s[ls-i-1]!="w":ans+=1
        elif s[i]=="(":
            if s[ls-i-1]!=")":ans+=1
        elif s[i]==")":
            if s[ls-i-1]!="(":ans+=1        
print(ans)


Measured memory_bytes: 5572
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    Q, *BC = map(int, read().split())

    total = sum(A)
    d = [0] * (10 ** 5 + 1)
    for a in A:
        d[a] += 1

    for b, c in zip(*[iter(BC)] * 2):
        total += (c - b) * d[b]
        d[c] += d[b]
        d[b] = 0
        print(total)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 113848
#include<iostream>
using namespace std; 
int main(){
  double v,y,t;
  int i;
  while(cin>>v){
    t=v/9.8;
    y=4.9*t*t;
    for(i=0;y>=0;i++){
      y-=5.0;
    }
    cout<<i+1<<endl;
    
  }
}

Measured memory_bytes: 1224
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	for (int i = (S.size() / 2-1);i>=1;--i) {
		string S1 = S.substr(0, i);
		string S2 = S.substr(i, i);
		if (S1 ==S2) {
			cout  << i * 2 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll a,b;
  cin>>a>>b;
  ll N;
  cin>>N;
  ll s[N];
  for(int i=1; i<=999; ++i){
  cin>>s[i];
  }
  s[1]=1;
  for(int i=2; i<=999; ++i){
  s[i]=s[i-1]+i;}
  for(int i=1; i<=999; ++i)
  if(s[i]-a==s[i+1]-b)
  cout<<s[i]-a<<endl;
  return 0;
}
  
  
  
  
  

  
  

 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	vector<string> a(3);
	rep(i,3) cin>>a[i];
	string d="";
	rep(i,3){
	d+=(a[i][0]-'a')+'A';
	}
	cout<<d;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
s1 = 0
s2 = 0
for i in range(0, n, 2):
    s1 += a[i]
for i in range(1, n, 2):
    s2 += a[i]
print(s1 - s2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
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;}
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; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   ll k;
           cin>>k;
           //一周したら全要素-1
           ll n=50;
           vll a(n,0);
           ll time=k/n;
           ll r=k%n;
           rep(i,0,r){
             a[i]+=n+1;
           }
           rep(i,0,n){
            a[i]+=n-r-1+time; 
           }
           
           cout<<n<<endl;
           rep(i,0,n)cout<<a[i]<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n;
    cin>>n;
    int a[n];
    rep(i,n){cin>>a[i];}
    sort(a,a+n);
    int sum[n];
    sum[0]=0;
    int now=a[0];
    int res=1;
    for(int i=1;i<n;i++){
        if(now==a[i]){
            sum[i]=sum[i-1]+1;
        }else{
            now=a[i];
            sum[i]=sum[i-1];
            res++;
        }
    }
    DEBUG{cout << res << endl;}
    int diff=n+1;
    for(int i=1;i<n;i++){
        diff=min(diff,abs(sum[n-1]-2*sum[i]));
    }
    if(diff%2){res--;}
    cout << res << endl;
    return 0;
}


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

data=[10**5+1]*(n+1)
for _ in range(m):
    l,r=map(int,input().split())
    if(r < data[l]):
        data[l]=r
    

ans=1
i=1
tmpr=data[1]
while(1):
    i+=1
    if(n<i):
        break
    if(data[i] < tmpr):
        tmpr=data[i]
    if(tmpr <= i):
        if(data[i]!=10**5+1):
            ans+=1
            tmpr=data[i]

print(ans)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;
typedef long long ll;

ll n, i, x = 1, y = 2, ans, a[N], pre[N];

inline ll p(ll l, ll r){return pre[r] - pre[l - 1];}

bool bak(ll x, ll y, ll z){
	ll a1 = p(x, y - 1);
	ll a2 = p(y, z);
	ll a3 = p(x, y);
	ll a4 = p(y + 1, z);
	ll f1 = max(a1, a2) - min(a1, a2);
	ll f2 = max(a3, a4) - min(a3, a4);
	return f2 <= f1;
}

ll hesapla(){
	ll a1 = p(1, x - 1);
	ll a2 = p(x, i);
	ll a3 = p(i + 1, y - 1);
	ll a4 = p(y, n);
	return max(max(a1, a2), max(a3, a4)) - min(min(a1, a2), min(a3, a4));
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	for(ll i = 1; i <= n; i++){
		scanf("%lld",a+i);
		pre[i] = pre[i - 1] + a[i];
	}
	ans = pre[n];
	for(i = 1; i <= n; i++){
		y = max(y, i);
		while(x < i and bak(1, x, i))
			x++;
		while(y < n and bak(i + 1, y, n))
			y++;
		ans = min(ans, hesapla());
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5888
A, B, C, K = map(int, input().split())

if K % 2 == 1:
    ans = B - A
    if abs(ans) > 10**18:
        print("Unfair")
    else:
        print(ans)
else:
    ans = A - B
    if abs(ans) > 10**18:
        print("Unfair")
    else:
        print(ans)

Measured memory_bytes: 2940
import java.util.*;
import java.util.stream.*;

/**
 * (X,Y) の距離 |X|+|Y|
 * |X|+|Y| ＝ nK - 2m となる n, m (n=1,.. m=0,1,..) が存在すれば到達可能
 * 注意が必要なパターン
 *  K=3, |X|+|Y|=4 では n=1 とできない。
 *  n=2 とすると、m=1 として解がある。(n = (|X|+|Y|)/K ではない )
 *  n = (|X|+|Y|)/(K/2*2) とする必要がある。
 *
 * 例示方針：(X,Y) まで距離が2K以内のところに行く(X軸優先)。
 *           最後の二打で距離を調整。
 */
public class Main {
	Scanner sc;

	int X, Y, K;
	
//=============
// constructor
//
	public Main() {
		sc = new Scanner(System.in);
	}
	
//==================
// instance methods
//
	/**
	 * アルゴリズム本体
	 * 
	 * (0) 残り距離がK以下の場合特殊処理
	 * (1) X軸優先で残り距離が K より大きく 2K 以下になるようにする。
	 * (2) 残り 2 打で調整
	 */
	private void calc() {
		K = sc.nextInt();
		X = sc.nextInt();
		Y = sc.nextInt();

		int D = d(X, Y);
		if (D == K) {
			// 一発でいける特例
			out(1);
			out(X+" "+Y);
			return;
		}
		//
		if ((D%2 == 1) && ( K%2 ==0)) { // できない場合
			out(-1);
			return;
		}

		boolean near = false; // もともと近くかつ K 未満の距離の場合、1 発目はイレギュラー
		int n = (D + (K-1)) / K; // 打数(繰り上げ)
		if (n == 1) {
			near = true;
			n++;
		}

		long mm;
		boolean added = false;
		while (true) {
			mm = (long)K * n - D;
			if (mm%2 == 0) break;
			n++;
			added = true;
		}
		int m = (int)(mm / 2); // 無駄にする量の半分
		out(n); // 確定した打数を出力

		// 2 打残して X 軸優先で近づく
		int dx = (X >= 0)?1:-1;
		int dy = (Y >= 0)?1:-1;

		// 第一象限に限定(XX, YY)がゴール
		int XX = dx * X;
		int YY = dy * Y; 

		//
		int lx = 0;
		int ly = 0;
		if (near && added) {
			lx -= K;
			out(dx*lx + " " + dy*ly);
			n--;
			m -= K;
		}

		for (int i = 0; i < n-2; i++) {
			if (XX > lx) {
				lx += K;
				if (lx > XX) {
					ly += (lx - XX);
					lx = XX;
				}
			} else {
				ly += K;
			}
			out(dx*lx + " " + dy*ly); // 象限を戻して出力
		}

		// あと 2 打でゴール
		if (lx == XX) {
			// 真下に来たパターン
			lx += m; ly += K-m;
			out( dx*lx + " " + dy*ly );
			lx -= m; ly += K-m;
			out( dx*lx + " " + dy*ly );
			return;
		} else if (ly == YY) {
			// 真左に来たパターン
			lx += K-m; ly += m;
			out( dx*lx + " " + dy*ly );
			lx += K-m; ly -= m;
			out( dx*lx + " " + dy*ly );
			return;
		} else {
			// 左下に来たパターン
			if (XX-lx > YY-ly) {
				lx += K-m;
				ly -= m;
			} else {
				lx -= m;
				ly += K-m;
			}
			out( dx*lx + " " + dy*ly );
			out( X + " " + Y );
		}
	}
	
	/**
	 *  マンハッタン距離
	 */
	private int d(int x, int y) {
		return d(x) + d(y);
	}
	private int d(int x) {
		return (x>=0)?x:-x;
	}

	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
//======
// main
//
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

}

Measured memory_bytes: 46736
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__



void solve(void){
  
  int A,B;
  cin >> A >> B;
  
  int nmax=-100000;
  
  chmax(nmax, A+B);
  chmax(nmax, A-B);
  chmax(nmax, A*B);

  cout << nmax << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

char s[10];
bool eq(int a,int b,int c,char o){
  return (s[a]==o && s[b]==o && s[c]==o);
}

int main(){
  while(~scanf("%s",s)){
    bool owin = false;
    owin |= eq(0,1,2,'o');
    owin |= eq(3,4,5,'o');
    owin |= eq(6,7,8,'o');
    owin |= eq(0,3,6,'o');
    owin |= eq(1,4,7,'o');
    owin |= eq(2,5,8,'o');
    owin |= eq(0,4,8,'o');
    owin |= eq(2,4,6,'o');
    bool xwin = false;
    xwin |= eq(0,1,2,'x');
    xwin |= eq(3,4,5,'x');
    xwin |= eq(6,7,8,'x');
    xwin |= eq(0,3,6,'x');
    xwin |= eq(1,4,7,'x');
    xwin |= eq(2,5,8,'x');
    xwin |= eq(0,4,8,'x');
    xwin |= eq(2,4,6,'x');
    if(owin)cout<<"o"<<endl;
    else if(xwin)cout<<"x"<<endl;
    else cout<<"d"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    string s;
    cin>>s;
    int x1=0,x2=0,n=0;
    vector<pair<char,int>> t;
    rep(i,s.length()){
        if(s[i]!='x'){
            n++;
            t.push_back(make_pair(s[i],i));
        }
    }
    if(n==0){
        out(0);
        return 0;
    }
    int counter=0;
    for(int i=0;i<n;i++){
        counter+=(t[i].first==t[n-1-i].first);
    }
    if(counter!=n){
        out(-1);
        return 0;
    }
    int ans=0,l=0,r=s.length()-1;
    while(l<r){
        //debug(s[l],s[r]);
        if(s[l]==s[r]){
            l++;
            r--;
        }else if(s[l]=='x'&&s[r]!='x'){
            ans++;
            l++;
        }else if(s[l]!='x'&&s[r]=='x'){
            ans++;
            r--;
        }
    }
    out(ans);
}

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

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef int Capacity;
struct Dinic {
    int n, s, t;
    vector<int> level, progress, que;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    Dinic(int n)
        : n(n), cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
          g(n, vector<int>()), inf(numeric_limits<Capacity>::max()/8){}
    Dinic(const Graph &graph){
        *this = Dinic(graph.size());
        for(int i = 0; i < n; i++) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
    }
    void addEdge(int u, int v, Capacity c){
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        g[u].push_back(v); g[v].push_back(u);
    }
    inline Capacity residue(int u, int v){ return cap[u][v] - flow[u][v]; }
    Capacity solve(int s, int t){
        this->t = t, this->s = s;
        que.resize(n+1);
        Capacity res = 0;
        while(levelize()){
            progress.assign(n, 0);
            res += augment(s, inf);
        }
        return res;
    }
    bool levelize(){
        int l = 0, r = 0;
        level.assign(n, -1); level[s] = 0;
        que[r++] = s;
        while(l != r){
            int v = que[l++];
            if(v == t) break;
            for(const int &d : g[v]){
                if((level[d] != -1 && level[d] <= level[v] + 1) || residue(v,d) == 0) continue;
                level[d] = level[v] + 1; que[r++] = d;
            }
        }
        return level[t] != -1;
    }
    Capacity augment(int v, Capacity lim){
        Capacity res = 0;
        if(v == t) return lim;
        for(int &i = progress[v]; i < (int)g[v].size(); i++){
            const int &d = g[v][i];
            if(residue(v,d) == 0 || level[v] >= level[d]) continue;
            const Capacity aug = augment(d, min(lim, residue(v,d)));
            flow[v][d] += aug; flow[d][v] -= aug;
            res += aug; lim -= aug;
            if(lim == 0) break;
        }
        return res;
    }
};

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

int dp[500][500];
int gcd(int a, int b){
    return a < 500 && b < 500 ? dp[a][b] : b == 0 ? a : gcd(b, a%b);
}


int main(){
    rep(i,500)rep(j,i+1) dp[i][j] = dp[j][i] = __gcd(i,j);
    ios::sync_with_stdio(0);
    cin.tie(0);
    #define endl "\n"
    int n,m;
    while(cin >> n >> m && n|m){
        vector<int> a(n), b(m);
        rep(i,n) cin >> a[i];
        rep(i,m) cin >> b[i];
        Dinic d(n+m+2);
        int s = n+m, t = n+m+1;
        rep(i,m) d.addEdge(i+n,t,1);
        rep(i,n){
            d.addEdge(s,i,1);
            rep(j,m) if(gcd(a[i],b[j]) != 1) d.addEdge(i,n+j,1);
        }
        cout << d.solve(s,t) << endl;
    }
}

// int main(){
//     int N,M;
//     cin >> N >> M;
//     Graph g(N);
//     rep(i,M){
//         int a,b,c;
//         cin >> a >> b >> c;
//         g[a].emplace_back(a,b,c);
//     }
//     Dinic dinic(g);
//     cout << dinic.solve(0,N-1) << endl;
// }

Measured memory_bytes: 11568
import numpy as np

H, W = [int(elem) for elem in input().split(' ')]
grid = np.array([list(input()) for _ in range(H)])
assert len(grid) == H
assert len(grid[0]) == W

ans_grid = [['#'] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            continue
        elif i == 0 and j == 0:
            count = sum([1 if string == '#' else 0 for string in grid[0:2,0:2].flatten()])
        elif i == 0:
            count = sum([1 if string == '#' else 0 for string in grid[0:2, j - 1:j + 2].flatten()])
        elif j == 0:
            count = sum([1 if string == '#' else 0 for string in grid[i - 1:i + 2, 0:2].flatten()])
        else:
            count = sum([1 if string == '#' else 0 for string in grid[i - 1:i + 2, j - 1:j + 2].flatten()])
        ans_grid[i][j] = str(count)

for ans_row in ans_grid:
    print("".join(ans_row))


Measured memory_bytes: 12776
#include <stdio.h>
int main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4;
	scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x3 - (y3 - y2);
	y4 = y3 + (x3 - x2);
	printf("%d %d %d %d",x3,y3,x4,y4); 
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n; cin >> n;
  int ans = 0;
  for(int i = 0; i<n; i++){
    int ai; cin >> ai;
    bool isPrime = true;
    for(int j = 2; j*j<=ai; j++){
      if(ai % j == 0 ) isPrime = false;
    }
    if( isPrime )  ans++;
  }
  cout << ans << "\n";
}



Measured memory_bytes: 3096
def a():
    n = int(input()) % 10
    if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
        print('hon')
    elif n == 3:
        print('bon')
    else:
        print('pon')




# def b():

# def c():
    

# def d():


a()

Measured memory_bytes: 9024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    string s;
    cin >> s;
    vector<string> v = {"dream", "dreamer", "erase", "eraser"};
    bool ans = false;
    int i = s.length();
    while (i >= 5) {
        ans = false;
        for (auto ss : v) {
            if (ss.length() > i) continue;
            if (s.substr(i-ss.length(), ss.length()) != ss) continue;
            ans = true;
            i -= ss.length();
            break;
        }
        if (!ans) break;
    }
    cout << (ans?"YES":"NO") << endl;
}


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

int n,l[205],ans;

void work()
{
	scanf("%d",&n),n*=2;
	for (int i=1; i<=n; i++)  scanf("%d",&l[i]);
	sort(l+1,l+n+1);
	for (int i=1; i<=n; i+=2)  ans+=l[i];
	printf("%d",ans);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
using namespace std;
//using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=1e10+7;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a);
        }
        a=(a*a);
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;

    string str,t;
    cin>>str>>t;

    string s=t.substr(0,t.size()-1);
    
    if(s==str) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3612