akhauriyash/Code-Regression huggingface dataset:
import sys
import pprint
from collections import deque
import itertools

def bfs(i,j,maze,depth):
    queue = deque([[i,j]])
    depth[i][j] = 0
    while queue:
        x, y = queue.popleft()

#現在地が壁の中のときスキップ
        if maze[x][y] == '#':
            continue

#四方へ移動したときに壁の中、もしくは探索済ならスキップ
        for a,b in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_x, new_y = x+a, y+b
            if maze[new_x][new_y] == '#' or depth[new_x][new_y] >= 0:
                pass

#そうでなければ深さを１足してキューへ保存
            else:
                depth[new_x][new_y] = depth[x][y] + 1
                queue.append([new_x, new_y])

#深さマップを平坦化して最大値を出力
    return max(list(itertools.chain.from_iterable(depth)))


def main():
    H, W = list(map(int, input().split()))
    maze = [['#'] * (W+2) for _ in range(H+2)]

#外側を壁で囲った迷路入力
    for m in range(1,H+1):
        maze[m][1:W+1] = list(input())

    ans = []
    for i in range(1, H+1):
        for j in range(1, W+1):

#深さマップの初期化
            depth = [[-1] * (W+2) for __ in range(H+2)]
            ans.append(bfs(i,j,maze,depth))

    print(max(ans))

main()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define inf 1000000099
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
#define pb push_back


int32_t main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
  #endif
 
      int a,b;
      cin>>a>>b;
      cout<<a*b<<endl;  


}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n;

ll a,b,c;

int main(){
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a+b+1<c)printf("%lld\n",(a+b)*2+1-a);
    else printf("%lld\n",b+c);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N)
  cin >> A[i];
  vector<int> L(N), R(N);
  L[0] = R[0] = 0;
  REP(i, N - 1)
  {
    L[i + 1] = gcd(A[i], L[i]);
    R[i + 1] = gcd(A[N - 1 - i], R[i]);
  }
  int ans = 0;
  REP(i, N)
  ans = max(ans, gcd(L[i], R[N - 1 - i]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
/*input
0 0 1 2
*/

#include <iostream>

using namespace std;

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	for(int i=sy;i<ty;i++){
		cout << "U";
	}
	for(int i=sx;i<tx;i++){
		cout << "R";
	}
	for(int i=ty;i>sy;i--){
		cout << "D";
	}
	for(int i=tx;i>sx-1;i--){
		cout << "L";
	}

	for(int i=sy;i<ty+1;i++){
		cout << "U";
	}
	for(int i=sx;i<tx+1;i++){
		cout << "R";
	}
	cout << "DR";
	for(int i=ty;i>sy-1;i--){
		cout << "D";
	}
	for(int i=tx;i>sx-1;i--){
		cout << "L";
	}
	cout << "U" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	string N, M;
	ll sum=0;
	cin >> N >> M;
	if (N == "H")sum += 1;
	if (M == "H")sum += 1;
	if (sum % 2 == 0)cout << "H";
	else cout << "D";

	return 0;
}

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

int main(){
    long long n;
    cin>>n;
    long long a[n+1];
    map<long long,long long>m;
    long long ans=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ans+=m[a[i]-i];
        m[-a[i]-i]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 27716
import sys
sys.setrecursionlimit(500000)

N, K = map(int, input().split())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

Closed = [False] * (N+1)
Close_cnt = [1] * (N+1)
ans = 1
mod = 10**9 + 7
def dfs(n, start=False):
    global ans
    Closed[n] = True
    if start:
        Close_cnt[n] = 0
    col = K
    for v in E[n]:
        if Closed[v]:
            col -= Close_cnt[v]
    ans = ans * col % mod
    Close_cnt[n] += 1

    for v in E[n]:
        if not Closed[v]:
            dfs(v)
            Close_cnt[n] += 1
dfs(1, True)
print(ans)


Measured memory_bytes: 102984
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	ll ma, mb, ans;
	if(n%2 == 1){
		ma = a[n/2];
		mb = b[n/2];
		ans = mb - ma + 1;
	}
	else{
		ma = (a[(n-1)/2] + a[n/2]);
		mb = (b[(n-1)/2] + b[n/2]);
		ans = mb - ma + 1;
	}
	cout << ans << endl;
	return 0;
}

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

#define M 1000000007
#define FOR(i, s, n) for (ll i = (s); i < (n); ++i)
#define FORALL(i, n) for (ll i = 0; i < (n); ++i)
#define MOD 1000000007
#define ff first
#define ss second
#define pll pair<long long, long long>
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(false)
#define countbits(x) __builtin_popcount(x)
#define pb(x) push_back((x))
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define print(x) cout << x << endl
#define debug print("reaching\n")
#define mll map<ll,ll>
#define lsb(i) i&(-i)
#define printv(x) \
	FORALL(i, x.size()) \
	{ \
		cout << x[i] << ' '; \
	} \
	cout << endl \
;
#define printm(m) \
	for(auto i: m){\
		cout<<i.ff<<' '<<i.ss<<endl; \
	}\
;
// vector<map<ll,ll>> m(2);
long long binpow(long long a, long long b) {
	if(b<=0) return 1;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}



template <typename T>
T extGcd(T a, T b, T &x, T &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	else
	{
		int g = extGcd(b, a % b, y, x);
		y -= a / b * x;
		return g;
	}
}

template <typename T>
T modInv(T a, T m)
{
	T x, y;
	extGcd(a, m, x, y);
	return (x % m + m) % m;
}


int main()
{
	fast;
	// cin.tie(0);
	// cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	int t=1;
	// cin>>t;
	ll tot=t;
	while(t--){
		string s;
		string t;
		cin>>s;
		cin>>t;
		ll ans= INT_MAX;
		for(int i = 0; i < s.length(); i++){
			if(s.length() - i < t.length()) break;
			ll temp = 0;
			int index = i;
			for(int j = 0; j<t.length(); j++){
				if(s[index++]==t[j]) continue;
				temp++;
			}
			ans = min(ans, temp);
		}
		print(ans);
	}
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = (b % a ? b - a : a + b);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
rows = list(map(int,input().split()))
a = list()
b = list()
for i in range(rows[0]):
    a.append(list(map(int,input().split())))

for i in range(rows[1]):
    b.append(list(map(int,input().split())))

c = [[0]*rows[2] for i in range(rows[0])]
for i in range(rows[0]):
    for j in range(rows[2]):
        for k in range(rows[1]):
            c[i][j] += a[i][k]*b[k][j]


for i in range(rows[0]):
    print(*c[i])


Measured memory_bytes: 7052
def main():
  n,y=map(int,input().split())
  for i in range(n+1):
    for j in range(n+1-i):
      if 10**3*(i+5*j+10*(n-i-j))==y:
        print(n-i-j,j,i)
        exit()
  print(-1,-1,-1)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 3060
import java.io.*;
 
class Main {
	
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			String[] nums = kb.readLine().split( " " );
			int[] A = new int[n];
            int i, j;
            
            for( i=0; i<n; i++ ) {
            	A[i] = Integer.parseInt( nums[i] );
            }
            
            int cnt = 0;
			cnt = bubbleSort( A );
			
            StringBuilder output = new StringBuilder( 200+1 );
            for( i=0; i<n; i++ ) {
            	output.append( A[i]  );
            	output.append( " "  );
            }
            output.deleteCharAt( output.lastIndexOf( " " ) );

            System.out.println( output );
            System.out.println( cnt );
			 
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }        
    }
    
    static int bubbleSort( int[] A ) 
    {
    	int tmp;
    	int i, j, cnt;
    	int n = A.length;
    	
    	cnt = 0;
   		for( i=0; i<n; i++ ) {
   			for( j=n-1; i<j; j-- ) {
   				if( A[j] < A[ j-1 ] ) {
   					tmp = A[ j-1 ];
   					A[ j-1 ] = A[ j ];
   					A[ j ] = tmp;
   					cnt++;
   				}
   			}
   		}
   		return cnt;
    }
}

Measured memory_bytes: 16908
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(void){
  int n,i,fs=0,ans;
  string s;
  cin >> n >> s;
  for (i=1;i<n;i++) if (s.at(i)=='E') fs++;
  ans=fs;
  for (i=1;i<n;i++){
    if (s.at(i-1)=='W') fs++;
    if (s.at(i)=='E') fs--;
    ans=min(ans,fs);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 900
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            boolean[] b = new boolean[8];
            int cntOver = 0;
            for (int x : a) {
                x /= 400;
                if (x >= 8) cntOver++;
                else b[x] = true;
            }

            int cnt = 0;
            for (int i = 0; i < 8; i++) {
                if (b[i]) cnt++;
            }

            int max = cntOver + cnt;
            int min = cnt == 0 ? 1 : cnt;

            out.println(min + " " + max);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

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

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21332
#include <stdio.h>

int rank(int rate) {
	if (1 <= rate && rate <= 399) return 0;
	if (400 <= rate && rate <= 799) return 1;
	if (8000 <= rate && rate <= 1199) return 2;
	if (1200 <= rate && rate <= 1599) return 3;
	if (1600 <= rate && rate <= 1999) return 4;
	if (2000 <= rate && rate <= 2399) return 5;
	if (2400 <= rate && rate <= 2799) return 6;
	if (2800 <= rate && rate <= 3199) return 7;
	return 8;
}

int main(void) {
	char exists[16] = {0};
	int koteiCount = 0;
	int ziyuuCount = 0;
	int N;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int a, r;
		if (scanf("%d", &a) != 1) return 1;
		if (3200 <= a) {
			ziyuuCount++;
		} else {
			r = rank(a);
			if (!exists[r]) {
				koteiCount++;
				exists[r] = 1;
			}
		}
	}
	printf("%d %d\n", koteiCount == 0 && ziyuuCount > 0 ? 1 : koteiCount, koteiCount + ziyuuCount);
	return 0;
}


Measured memory_bytes: 128
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  ioso
  #ifndef ONLINE_JUDGE
  ffe
  #endif
  string s, ss; cin >> s >> ss;
  int cnt=INT_MAX;
  for(int i=0;i<(s.length()-ss.length()+1);i++) {
    string k = s.substr(i,ss.length());
    //cout << k << endl;
    int cn=0;
    for(int j=0;j<ss.length();j++) {
      if(k[j] != ss[j]) {
        cn++;
      }
    }

    cnt = min(cn,cnt);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)
	{
		cout<<"No\n";
	}
	else if(a==b&&a!=c)
	{
		cout<<"Yes\n";
	}
	else if(b==c&&b!=a)
	{
		cout<<"Yes\n";
	}
	else if(a==c&&a!=b)
	{
		cout<<"Yes\n";
	}
		else if(a!=c&&a!=b)
	{
		cout<<"No\n";
	}
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Control.Monad.ST
import Data.Array.ST
import Data.Function
import qualified Data.Vector.Unboxed as VU

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- VU.fromList <$> getIntList
    print $ solve n as

solve n as = runST $ do
    arr <- newArray ((0,0),(n-1,n-1)) 0 :: ST s (STUArray s (Int,Int) Int)
    forM_ [n-1,n-2..0] $ \i -> do
        forM_ [i..n-1] $ \j -> do
            if i == j then
                writeArray arr (i,j) (as VU.! i)
            else do
                x <- readArray arr (i+1,j)
                y <- readArray arr (i,j-1)
                writeArray arr (i,j) $ max (as VU.! i - x) (as VU.! j - y)
    readArray arr (0,n-1)

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

int main()
{
	int n;
    cin>>n;
  	int i,h[n];
    for(i=0;i<n;i++)
      cin>>h[i];
    int dp[n]={0};
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++)
    {
	  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
  cout<<dp[n-1];
}

Measured memory_bytes: 4348
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line;
            HashMap<String, Integer> hm = new HashMap<String,Integer>();
            
            while((line=br.readLine())!=null){
                if(line.equals(""))break;
                String[] splited = line.split(" ");
                for(String str:splited){
                    if(hm.containsKey(str))hm.put(str,hm.get(str)+1);
                    else hm.put(str,1);
                }
                String mostFreq="", mostLong="";
                int freq=0;
                for(String key:hm.keySet()){
                    if(hm.get(key)>freq){freq=hm.get(key);mostFreq=key;}
                    if(key.length()>mostLong.length()) mostLong=key;
                }
                System.out.println(mostFreq+" "+mostLong);
            }
        }catch(Exception e){e.printStackTrace();}
    }
}

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

int main(){
  string s;
  cin >> s;
  
  bool ok = true;
  int l = s.size();
  int ccnt = 0;
  if(s.at(0) != 'A') ok = false;
  for(int i = 2; i < l-1; i++){
    if(s.at(i) == 'C') ccnt++;
  }
  if(ccnt != 1) ok = false;
  ccnt = 0;
  for(int i = 1; i < l; i++){
    char c = s.at(i);
    if(c < 'a') ccnt++;
    if(c > 'z') ccnt++;
  }
  if(ccnt != 1) ok = false;
  
  if(ok) cout << "AC" << endl;
  else cout << "WA"  << endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
	int i;
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)ans+=i;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int n; cin >> n;
    vector<pair<int, int>> a;

    for (int i = 1; i <= n; ++i) {
        int inp; cin >> inp;
        a.push_back(make_pair(inp, i));
    }

    sort(a.begin(), a.end());

    for (auto i : a) {
        cout << i.second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1780
#include <iostream>
#include<string>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	bool flag1 = true;
	bool flag2 = false;
		for (int j = S.size()-T.size(); j >=0; --j) {
			flag1 = true;
			if (S[j] == T[0] || S[j] == '?') {
				for (int k = j; k < T.size() + j; ++k) {
					if (S[k] == '?'||S[k]==T[k-j]) {
						continue;
					}
					else {
						flag1 = false;
						break;
					}
				}//可能であることが分かったのでSの一部をTに変える作業
				if (flag1) {
					for (int k = j; k < j + T.size(); ++k) {
						S[k] = T[k - j];
					}
					flag2 = true;
					j -= 100;
				}
			}
		}
	//そもそも可能かどうか.可能なら?を全部aに変える
	if (flag2) {
		for (int i = 0; i < S.size(); ++i) {
			if (S[i] == '?') {
				S[i] = 'a';
			}
		}
		cout << S << endl;
	}
	else {
		cout << "UNRESTORABLE" << endl;
	}
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l, r;
    
    l = max(a, c);
    r = min(b, d);
    
    cout << max(0, r - l) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	#define mp make_pair
	int mcd(int a,int b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}		
	int v[MaxN];		
	int c[MaxN];
int main(){
	lli N,K,i,j,s=0,p,q;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>v[i];
	}
	for(i=0;i<N;i++){
		cin>>c[i];
	}
	for(i=0;i<N;i++){
		if(v[i]-c[i]>0){
			s+=v[i]-c[i];
		}
	}
	cout<<s;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int n, m;
int a, b;
bool s[200005], t[200005];

int main(){
	cin >> n >> m;
	FORI(0, m) {
		cin >> a >> b;
		if (a == 1) {
			s[b] = 1;
		}
		if (b == n) {
			t[a] = 1;
		}
	}
	FORI(0, n) {
		if (s[i]==1 && t[i]==1) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
		
	return 0;
}


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


int main() {
  int N, Y;
  cin >> N >> Y;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  for (int a = 0; a <= N; a++) {
    for (int  b = 0; b + a <= N; b++) {
      int c = N - a - b;
      int total = 10000 * a + 5000 * b + 1000 * c;
      if (total == Y) {
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


Measured memory_bytes: 256
N=int(input())
B= list(map(int,input().split()))

ret=0
bs=0
for i,b in enumerate(B):
  if i==0:
    ret+=b
  else:
    if bs<b:
      ret+=bs
    else:
      ret+=b
  bs=b

ret+=B[-1]
print(ret)
  

Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<ll> X(N), L(N);
    vector< pair<ll, ll> > seg;
    for(int i=0; i<N; i++) {
        cin >> X[i] >> L[i];
        seg.emplace_back(X[i] - L[i], X[i] + L[i]);
    }

    sort(seg.begin(), seg.end(), [&](auto x, auto y) {
            return x.second < y.second;
        });

    ll pre = -LONGINF, ans = 0;
    for(int i=0; i<N; i++) {
        if(pre <= seg[i].first) {
            ans++;
            pre = max(pre, seg[i].second);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4980
#include<stdio.h>
int main(){

  int a, b, c, t;
  scanf("%d %d %d", &a, &b, &c);
 
  if( a > b ){
    t = a, a = b, b = t;}
  if( b > c ){
    t = b, b = c, c = t;}
  if( a > b){
    t = a, a = b, b = t;}
  printf("%d %d %d\n", a, b, c);


   return 0;
}

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

char x[110];
int main()
{
	int a;
	scanf("%d",&a);
	scanf("%s",x+1);
	int b = strlen(x+1);
	if(b<=a) printf("%s",x+1);
	else
	{
		for(int i=1;i<=a;i++) printf("%c",x[i]);
		printf("...");
	}
}

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


int main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	string str = "";
	for(int i=0; i<n; i++){
		str += s.at(i);
		str += t.at(i);
	}
	cout << str << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main(){
	int n;
	cin >> n;
	vector<lli> h(n);
	rep(i,n)cin >> h[i];
	vector<lli> ans(n);
	rrep(i,n){
	  if(i==n-1)ans[i]=0;
	  else {
		  if(h[i] >= h[i+1]){
			  ans[i]  = ans[i+1] + 1;
		  }else{
			  ans[i] = 0;
		  }
	  }
	}
	cout << *std::max_element(ans.begin(),ans.end())<<endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

typedef long long ll;

ll N,M; 

vector<vector<ll>> to;

vector<ll> dp; //初期値はマイナス1に設定

ll rec(ll i){
  if(dp[i] != -1){ return dp[i];}
  
  ll res = 0; //まだrec(i)がもとまっていなかったら、今から求める
  for(auto a:to[i]){
    res = max(res,rec(a) + 1);}
  
  return dp[i] = res;}

int main(){
  cin >> N >> M;
  to = vector<vector<ll>> (N);
  dp = vector<ll> (N,(ll)-1);
  for(ll i = 0; i < M; i++){
    ll x,y; cin >> x >> y; x--; y--;
    to[x].push_back(y);} //隣接リスト作成
  ll res = 0;
  for(ll i = 0; i < N; i++){
    res = max(res,rec(i));}
  
  cout << res << endl; return 0;}


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

int main() {
	int n, t;
	cin >> n >> t;
	vector<pair<int, int>> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i].first >> c[i].second;
		c[i].second = t - c[i].second;
	}

	int min = 10e4;
	for (int i = 0; i < n; i++)
		if (min > c[i].first && c[i].second >= 0)
			min = c[i].first;
	if (min == 10e4)
		cout << "TLE" << endl;
	else
		cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 20;
int N;
int a[100010], b[100010];
vector<int> G[100010];
int dis[2][100010];

void dfs(int idx, int cur) {
  for (int nxt : G[cur]) {
    if (dis[idx][nxt] != INF) continue;
    dis[idx][nxt] = dis[idx][cur] + 1;
    dfs(idx, nxt);
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    G[a[i]].emplace_back(b[i]);
    G[b[i]].emplace_back(a[i]);
  }
  fill_n((int*)dis, 2 * 100010, INF);
  dis[0][0] = dis[1][N - 1] = 0;
  dfs(0, 0);
  dfs(1, N - 1);
  int A = 0, B = 0;
  for (int i = 0; i < N; i++) {
    if (dis[0][i] <= dis[1][i]) A++;
    else B++;
  }
  cout << (A > B ? "Fennec" : "Snuke") << endl;

  return 0;
}

Measured memory_bytes: 12032
#include<iostream>
#include<cstdio>
typedef long long ll;
const ll mod=998244353;
const int N=3e5+5;
int n;ll a,b,k,C[N];
ll qpow(ll x,ll y) {
    ll res=1;
    for(;y;x=x*x%mod,y>>=1) if(y&1) res=res*x%mod;
    return res;
}
int main(){
    scanf("%d%lld%lld%lld",&n,&a,&b,&k);
    C[0]=1;for(int i=1;i<=n;i++) C[i]=C[i-1]*(n+1-i)%mod*qpow(i,mod-2)%mod;
    ll ans=0;
    for(int i=0;i<=n;i++) {
        ll v=k-i*a;
        if(v<0) continue;
        if(v%b||v/b>n) continue;
        ans+=C[i]*C[v/b]%mod;
    }
    printf("%lld\n",ans%mod);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,-1,-1,0,0,1,1,1 }, ty[8] = { -1,0,1,-1,1,-1,0,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll h, w, ans = INF2;

int main() {
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	ans = min(h, w);
	for (int i = 1;i < h;i++) {
		ll tp = i * w, l = (h - i)*(w / 2), r = (h - i)*(w - w / 2);
		ans = min(ans, max({ tp,l,r })-min({ tp, l, r }));
	}
	for (int i = 1;i < w;i++) {
		ll tp = i * h, l = (w - i)*(h / 2), r = (w - i)*(h - h / 2);
		ans = min(ans, max({ tp,l,r }) - min({ tp, l, r }));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def is_prime(x):
    if x == 1:
        return(False)
    y = 2
    while y < x:
        if x%y == 0:
            return(False)
        y += 1
    return(True)
 
n = int(input())
while True:
    if is_prime(n):
        print(n)
        break
    n += 1

Measured memory_bytes: 2940
//58
#include<iostream>

using namespace std;

int main(){
  for(int n,q;cin>>n>>q,n|q;){
    int cv[50][100]={{}};
    for(int i=0;i<n;i++){
      int m;
      cin>>m;
      while(m--){
	int d;
	cin>>d;
	cv[i][d]=true;
      }
    }
    int m=0,d;
    for(int i=1;i<100;i++){
      int c=0;
      for(int j=0;j<n;j++){
	c+=cv[j][i];
      }
      if(m<c){
	m=c;
	d=i;
      }
    }
    cout<<((q<=m)?d:0)<<endl;
  }
  return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int x;
  int ans = 0;
  
  while(n > 0){
    cin >> x;
    if(x <= k-x){
      ans += 2*x;
    }else{
      ans += 2*(k-x);
    }
    
    n--;
  }
  
  cout << ans << endl;
}

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

#define int long long
const int MN = 101234;
int perm[MN], d[MN], mark[MN], a[MN], ans[MN];

int32_t main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++)
		d[i] = a[i + 1] - a[i];
	for (int i = 0; i < n; i++)
		perm[i] = i;
	int m, k;
	cin >> m >> k;
	for (int i = 0; i < m; i++) {
		int s;
		cin >> s;
		swap(perm[s - 1], perm[s - 2]);
	}
	for (int i = 0; i < n; i++)
		cerr << perm[i] << '*';
	cerr << endl;
	for (int i = 0; i < n; i++) {
		if (!mark[i]) {
			vector <int> vec;
			int x = perm[i];
			mark[i] = true;
			vec.push_back(i);
			while (x != i) {
				vec.push_back(x);
				mark[x] = true;
				//cerr << x << ' ' << i << endl;
				x = perm[x];
				//cerr << x << ' ' << i << endl;
			}
			for (int i = 0; i < vec.size(); i++)
				ans[vec[i]] = vec[(i + k) % vec.size()];
			//for (int i: vec) 
				//cerr << i << ' ';
			//cerr << endl;
		}
	}
	int sum = a[0];
	for (int i = 0; i < n - 1; i++) {
		cout << sum << ".0" << ' ';
		sum += d[ans[i]];
	}
	cout << sum << ".0" << endl;
}


Measured memory_bytes: 5476
#include <bits/stdc++.h>
using namespace std;
int main() {
    static int tmp, ans;
    string S;
    cin >> S;
    int len = S.length();
    for(int i = 0; i < len; ++i) {
        if(S[i] == 'A' | S[i] == 'C' | S[i] == 'G' | S[i] == 'T')
            ++tmp;
        else {
            ans = max(ans, tmp);
            tmp = 0;
        }
        if(i == len - 1)
            ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;
typedef unsigned int uint;

int main(void)
{
    string S;
    cin >> S;
    
    int ret = 0;
    for(uint i = 0; i < S.length(); i++){
        for(uint j = i+1; j <= S.length(); j++){
            string sub = S.substr(i, j-i);
            bool isACGT = true;
            for (uint s = 0; s < sub.length(); s++){
                if (sub.substr(s,1) == "A" ||
                    sub.substr(s,1) == "C" ||
                    sub.substr(s,1) == "G" ||
                    sub.substr(s,1) == "T" ){

                    } else {
                        isACGT = false;
                        break;
                    }
            }
            if (isACGT && sub.length() > ret) {
                ret = sub.length();
            }
        }
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main(){
	int s;
	cin >> s;
	
	int ans=0;
	
	REP(i,6){
		if(s%10==1) ans++;
		s=s/10;
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define pb push_back
#define inin(x) int x; cin>>x;
#define ll long long
#define pb push_back

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

int main()
{
	int n;
	while (cin >> n&&n != 0)
	{
		vector<int> hana,taro;
		rep(i, n)
		{
			inin(x);
			taro.pb(x);
		}
		sort(taro.begin(), taro.end());
		repp(i, 1, 2 * n + 1)
		{
			if (!binary_search(taro.begin(), taro.end(), i))hana.pb(i);
		}
		
		int field=-1;
		while (1)
		{
			vector<int>::iterator t = upper_bound(taro.begin(), taro.end(), field);
			if ( t != taro.end())
			{
				field = *t;
				taro.erase(t);
			}
			else field = -1;

			if (taro.empty())
			{
				cout << hana.size() << endl << 0 << endl; break;
			}

			vector<int>::iterator h = upper_bound(hana.begin(), hana.end(), field);
			if (h != hana.end())
			{
				field = *h;
				hana.erase(h);
			}
			else field = -1;

			if (hana.empty())
			{
				cout << 0 << endl << taro.size() << endl; break;
			}
			
		}
	}
}

Measured memory_bytes: 1224
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

bool isOk(long[] arr, size_t idx, long key) {
	if (arr[idx] >= key) return true;
	return false;
}

size_t binsearch(long[] arr, long key) {
	long left = -1;
	long right = arr.length;

	while(right - left > 1) {
		long mid = left + (right - left) / 2;
		if (isOk(arr, mid, key)) right = mid;
		else left = mid;
	}
	return right;
}

void main() {
	int n;
	scanf("%d\n", &n);
	auto ws = readln.chomp.split.to!(long[]);
	auto total = ws.reduce!"a+b";
	auto ladder = new long[ws.length];
	ladder[0] = ws[0];
	foreach(i, w;ws[1..$])
		ladder[i+1] = ladder[i] + w;
	auto sep = binsearch(ladder, total/2);
	min(2*ladder[sep]-total, total-2*ladder[sep-1]).write;
}


Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int calc(int n, int d) {
  return n / d;
}

int main()
{
  int l, r, d;
  cin >> l >> r >> d;
  cout << calc(r, d) - calc(l - 1, d) << endl;
  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string ans;
  int L = S.size() * 2;
  for (int i = 0; i < L; i++)
  {
    if (i % 2 == 0)
      ans.push_back(S[i / 2]);
    else
      ans.push_back(T[i / 2]);
  }
  cout << ans << endl;
}


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

typedef long long ll;

ll n,a[202020];
int main()
{
    cin>>n;
    ll mx=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        if(a[i]%2)mx++;
    }
    if(mx)puts("first");
    else puts("second");
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

using namespace std;

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

    switch (n%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        default:
            cout << "bon" << endl;
            break;
    }

    return 0;
}



Measured memory_bytes: 3128
w=[]
n= int(input())

for i in range(n):
    w.append(input())


for i in range (n):
    for j in range (i+1,n):
        if w[i] == w[j]:
            print('No')
            exit()

for i in range (n-1) :
    if w[i][-1] != w[i + 1][0]:
        print('No')
        exit()


print("Yes")



Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
int main(){
    ll n,m;cin >> n >> m;
    ll c=m;
    m=n*n-m;
    vl v(n);rep(i,n)cin >> v[i];
    sort(all(v));//rev(all(v));
    ll ok=inf,ng=0;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        ll res=0;
        rep(i,n){
            ll key=mid-v[i];
            res+=upper_bound(all(v),key)-v.begin();
        }
        if(res>m)ok=mid;
        else ng=mid;
    }
    //cout << ok <<endl;
    vl cum(n+1,0);
    per(i,n)cum[i]+=cum[i+1]+v[i];
    //rep(i,n+1)cout << cum[i] <<" ";
    ll ans=0;
    rep(i,n){
        ll key=ok-v[i];
        ll t=n-(lower_bound(all(v),key)-v.begin());
        //cout << t <<endl;
        c-=t;
        ans+=v[i]*t+cum[n-t];
    }
    cout << ans+c*ok <<endl;
}   

Measured memory_bytes: 4844
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
vector<int> input(){
	int m;
	cin >> m;
	vector<int> x(m),y(m);
	vector<int> ret;
	for(int i=0;i<m;i++)cin >> x[i] >> y[i];
	for(int i=1;i<m;i++){
		ret.pb(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
		if(i<m-1){
			int cross = (x[i+1]-x[i])*(y[i]-y[i-1])-(y[i+1]-y[i])*(x[i]-x[i-1]);
			if(cross>0)ret.pb(1);
			else ret.pb(0);
		}
	}
	return ret;
}
bool same(vector<int> a,vector<int> b){
	if(a.size()!=b.size())return false;
	bool flag = true;
	for(int i=0;i<a.size();i++){
		if(a[i]!=b[i]){
			flag = false;
			break;
		}
	}
	if(flag)return true;
	flag = true;
	int len = (int)a.size();
	int d = (len+1)/2;
	for(int i=0;i<d;i++){
		if(a[2*i]!=b[len-1-(2*i)]){
			flag = false;
			break;
		}
	}
	if(!flag)return false;
	for(int i=0;i<d-1;i++){
		if(a[2*i+1]==b[len-1-(2*i+1)]){
			flag = false;
			break;
		}
	}
	if(!flag)return false;
	else return true;
}
int solve(){
	int n;
	cin >> n;
	if(!n)return 1;
	vector<vector<int> > L(n+1,vector<int>());
	for(int i=0;i<=n;i++)L[i] = input();
	for(int i=1;i<=n;i++){
		if(same(L[0],L[i]))printf("%d\n",i);
	}
	printf("+++++\n");
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    pf(ceil(a / d) >= ceil(c / b)? "Yes":"No");
    return 0;
}



Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define maxn 5005
#define LL long long
#define iv2 500000004
#define mod 1000000007
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--) 
using namespace std;

int n,f[maxn][maxn],sz[maxn],fac[maxn],pw[maxn],invf[maxn],inv[maxn];
vector<int>G[maxn];
int C2(int x){ return 1ll * x * (x-1) / 2 % mod; }

void dfs(int u,int ff){
	int v;f[u][1] = sz[u] = 1;
	rep(i,0,G[u].size()-1) if((v=G[u][i])^ff){
		dfs(v,u);
		static int g[maxn]={};
		rep(j,0,sz[u]+sz[v]) g[j] = 0;
		rep(j,0,sz[u]) rep(k,0,sz[v]) g[j+k] = (g[j+k] + 1ll * f[u][j] * f[v][k]) % mod;
		rep(j,0,sz[u]+sz[v]) f[u][j] = g[j];
		sz[u] += sz[v];
	}
	rep(j,1,sz[u]) if(j%2==0)
		f[u][0] = (f[u][0] + f[u][j] * 1ll * fac[j] % mod * pw[j/2] % mod * invf[j/2]) % mod;
	if(ff) f[u][0] = -f[u][0];
}

int main(){
	scanf("%d",&n);
	rep(i,1,n-1){
		int u,v;scanf("%d%d",&u,&v);
		G[u].push_back(v),G[v].push_back(u);
	}
	fac[0] = fac[1] = pw[0] = 1 , pw[1] = iv2;
	inv[0] = inv[1] = invf[0] = invf[1] = 1;
	rep(i,2,n) fac[i] = 1ll * fac[i-1] * i % mod , pw[i] = 1ll * iv2 * pw[i-1] % mod,inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod,
		invf[i] = 1ll * invf[i-1] * inv[i] % mod;
	dfs(1,0);
	printf("%d\n",f[1][0]);
}

Measured memory_bytes: 58660
fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun solve(sc: java.util.Scanner) {
    val N = sc.nextInt()
    val X = sc.nextInt()
    val Y = sc.nextInt()

    val d = Array(N) { 0 }
    for (i in 1 until N) {
        for (j in i + 1 until N + 1) {
            if (i == j) continue
            val m = listOf(
                Math.abs(i - j),
                Math.abs(X - i) + Math.abs(Y - j) + 1,
                Math.abs(X - j) + Math.abs(Y - i) + 1
            ).min()!!
            d[m] += 1
        }
    }

    for (i in 1 until N) {
        println(d[i])
    }
}


Measured memory_bytes: 110320
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int W,a,b; cin >> W >> a >> b;
    if(a<b) cout << max(0,b-a-W) << endl;
    else cout << max(0,a-W-b) << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool k = false;
    for (int i = 0;i <= a*b;i += a){
        if (i%b == c) k = true;
    }
    if (k){
        cout << "YES" << '\n';
    }else{
        cout << "NO" << '\n';
    }
}


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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl

#define N 200005
long long ans,ar[N];

int main() {

	fast_cin;
	
    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        cin >> ar[i];

        if(i >= 2) {
            ans += max(ar[i-1]-ar[i],0LL);
            ar[i] = max(ar[i], ar[i-1]);
        }
    }

    cout << ans << endl;
	
	
	return 0;
}

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

int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, cnt, a[n+m];
cin>>n>>m;
    for (int i =0; i<n; i++) {
a[i]=i*2;
}
    for (int j =n; j<n+m; j++) {
a[j]=j*2+1;
}
    for (int k=0; k<n+m; k++)
    {
        for (int l=k+1; l<n+m;l++)
        {
            if((a[k]+a[l])%2!=0){
continue;}else{
cnt++;
}; 
        }
    }
cout<<cnt<<"\n";
return 0;
}


Measured memory_bytes: 256