akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
   
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int s,i,j;
        int[] n=new int[3];
        for(i=0;i<3;i++){
            n[i]=scan.nextInt();
        }
        for(i=0;i<2;i++){
        	for(j=i;j<3;j++){
        		if(n[i]>n[j]){
        			s=n[i];
        			n[i]=n[j];
        			n[j]=s;
        		}
        	}
        }
        for(i=0;i<3;i++){
            System.out.print(n[i]);
            if(i==2)break;
            System.out.print(" ");
        }
        System.out.println("");
    }
}

Measured memory_bytes: 26224
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int A, B, C;

int main(void) {
  cin >> A >> B >> C;

  int s = 0;
  int t = C;
  REP(i, 0, 60) {
    while(t < s) t += 60;
    if(s <= t && t <= s + A) {
      cout << t << endl;
      return 0;
    }
    s += A + B;
  }

  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N;cin>>N;
  string S;cin>>S;
  int h = N/2;
  string s1 = S.substr(0,h),s2 = S.substr(h,h);
  if(N%2==1) cout<<"No"<<endl;
  else{
    if(s1==s2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int aR[100005];
int bR[100005];

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

    ll n;
    cin >> n;
    n /=2;
    ll a[n],b[n];
    F0R(i,n) {
      cin >> a[i] >> b[i];
      aR[a[i]]++;
      bR[b[i]]++;
    }
    int mostFreqA1 = 0;
    int mostFreqA2 = 0;
    int mostFreqB1 = 0;
    int mostFreqB2 = 0;

    int mostFreqA1Index = 0;
    int mostFreqA2Index = 0;
    int mostFreqB1Index = 0;
    int mostFreqB2Index = 0;

    F0R(i,100005){
        if(mostFreqA1 <= aR[i]) {
          // cout << "i - " << i << " : " << aR[i] << endl;
          mostFreqA2 = mostFreqA1;
          mostFreqA2Index = mostFreqA1Index;

          mostFreqA1 = aR[i];
          mostFreqA1Index = i;
        } else
        if(mostFreqA2 <= aR[i]){
          mostFreqA2 = aR[i];
          mostFreqA2Index = i;
        }

        if(mostFreqB1 <= bR[i]) {
          mostFreqB2 = mostFreqB1;
          mostFreqB2Index = mostFreqB1Index;

          mostFreqB1 = bR[i];
          mostFreqB1Index = i;
        }
        else if(mostFreqB2 <= bR[i]){
          mostFreqB2 = bR[i];
          mostFreqB2Index = i;
        }
    }
    if(mostFreqA1Index != mostFreqB1Index){
        cout << 2* n - mostFreqA1 - mostFreqB1 << endl;
        return 0;
    }
    // cout << mostFreqA1 << " " << mostFreqA2 << endl;
    // cout << mostFreqB1 << " " << mostFreqB2 << endl;
    ll ans = mostFreqA2 + mostFreqB1;
    if(mostFreqA1 + mostFreqB2 > ans) ans = mostFreqA1 + mostFreqB2;
    cout << 2*n - ans << endl;
    // cout << "asd";

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main(){
    int N; cin >> N;
    int B[N-1];
    int ans=0;
    for(int i=0; i<N-1; ++i){
        cin >> B[i];
    }

    for(int i=0; i<N; ++i){
        if(i == 0){
            ans+=B[0];
            continue;
        }
        if(i == N-1){
            ans+=B[N-2];
            break;
        }
        ans+=min(B[i], B[i-1]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
  }
  rep(i, n) {
    if (mp[a[i]] % 2 == 0) continue;
    mp[a[i]] = 0;
    ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<"\n";
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
// #define find(m,i) (m.find(i)!=m.end())
// #define find(m,i) (m.find(i)==m.end())
#define cYES cout<<"YES\n";
#define cNO cout<<"NO\n";
#define ins insert
#define imax 1000000000000000000
#define imin -1000000000000000000
// #define NP 50000
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
//  IIITA
//SUNEET KUMAR -->  ਸੁਨੀਤ
 
// scanning numbers extremely fast/////////
void fs(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
// ========================================
int power(int a,int x)
{
        a%=mod;
    int res=1;
    while(x>0)
    {
        if(x&1)
        res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int max(int a,int b)
{
    if(a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int min(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans%mod;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
 
void nhi_degi()
{
    set<string>s;
    int n;cin>>n;
    for(int i=1;i<=n;i++)
    {
        string temp;cin>>temp;
        s.ins(temp);
    }
    cout<<sz(s);el
}
signed main()
{
    // cases(t)
    // {
        nhi_degi();
    // }
}

Measured memory_bytes: 19180
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = lreads(N - 1);

    auto C = new long[][](N);
    foreach (i, a; A)
    {
        C[a - 1] ~= i + 1;
    }
    long height(long x)
    {
        if (C[x].empty)
            return 0;
        auto heights = new long[](C[x].length);
        foreach (i, c; C[x])
        {
            heights[i] = height(c);
        }
        heights.sort!"b<a"();
        long ret;
        foreach (i, h; heights)
        {
            ret = ret.max(h + i + 1);
        }
        dprint(x, C[x], heights, ret);
        return ret;
    }

    height(0).writeln();
}


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

string s;
bool ck(ll l,ll r){//[l,r]
    bool flg = true;
    rep(i,r-l+1){
        if(l+i>=r-i)break;
        if(s[l+i]!=s[r-i]){
            flg = false;
            break;
        }
    }
    return flg;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>s;
    bool ans = true;
    if(!ck(0,s.size()-1))ans = false;
    if(!ck(0,(s.size()-1)/2 -1))ans = false;
    if(!ck((s.size()+3)/2 -1, s.size()-1))ans = false;
    if(ans){
        print("Yes");
    }else{
        print("No");
    }
    return 0;
}

Measured memory_bytes: 256
import os

k = int(input())
x = 7
i = 1
if k%7==0:
    l = 9*k/7
else:
    l = 9*k

if l%2==0 or l%5==0:
    print(-1)
    exit()
else:
    a = 10%l
    for i in range(1,9000001):
        if a==1:
            print(i)
            break
        a = 10*a%l


Measured memory_bytes: 9108
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        char[] a = s.toCharArray();
        char[] alpha = new char[26];

        for (int i = 0; i < a.length; i++) {
            alpha[a[i] - 'a']++;
        }
        boolean flag = true;

        for (int n : alpha) {

            flag =(n%2==0);

            if(!flag) {
                break;
            }

        }
            if (flag) {
                System.out.println("Yes");
            } else System.out.println("No");
    }
}

Measured memory_bytes: 23252
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	if (b > a && c > a && b > c) ||
		(a > b && c > b && a > c) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
using System;

namespace ABC084_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = sss[0];
            var b = sss[1];
            var S = Console.ReadLine();
            var i = 0;
            var j = 0;

            if(!(S[a] == '-'))
            {
                Console.WriteLine("No");
                return;
            }
            var A = S.Substring(0, a);
            bool resultA = int.TryParse(A, out i);
            var B = S.Substring(a + 1, b);
            bool resultB = int.TryParse(B, out j);
            if(!(resultA == true && resultB == true))
            {
                Console.WriteLine("No");
                return;
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 11092
import itertools

n, m, q = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(q)]
cnt = 0

counter_l = list((itertools.combinations_with_replacement(range(1, m+1), n)))
for i in range(len(counter_l)):
    counter_l[i] = list(counter_l[i])


for j in counter_l:
    tmp = 0
    for k in range(q):
        if j[l[k][1] - 1] - j[l[k][0] - 1] == l[k][2]:
            tmp += l[k][3]
    cnt = max(cnt, tmp)

print(cnt)

Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

int main()
{
  int n,m,k;
  while(true)
    {
      cin>>n;
      if(n==0)
	exit(0);
      vector<int> p[101];
      vector<int> kk;    
      for(int j=0;j<n;j++)
	{
	  cin>>m;
	  for(int i=0;i<m;i++)
	    {
	      int t;
	      cin >>t;
	      p[j].push_back(t);
	    }
	}
      cin>>k;
      for(int i=0;i<k;i++)
	{
	      int t;
	      cin >> t;
	      kk.push_back(t);
	}
  
      int ans=-1;
      bool ans_s=false;
      for(int i=0;i<n;i++)
	{
	  int count=0;
	  for(int j=0;j<kk.size();j++)
	    {
	      for(int x=0;x<p[i].size();x++)
		{
		  if(p[i][x]==kk[j])
		    {
		   
		      count++;
		      break;
		    }
		}
	    }
	  if(count==kk.size())
	    {
	      if(ans_s==true)
		ans=-1;
	      else
		{
		  ans=i+1;
		  ans_s=true;
		}
	    }
	}
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 952
import java.util.Scanner;

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

  public void run() {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] buka = new int[n];
    for (int i = 0; i < n - 1; i++) {
      int joshi = sc.nextInt();
      buka[joshi - 1]++;
    }
    for (int i = 0; i < buka.length; i++) {
      System.out.println(buka[i]);
    }
  }
}

Measured memory_bytes: 61776
#include<bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
using namespace std;
template <class T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <class T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;

int n,x,y;
int cnt[2005];

int getdis(int s,int t)
{
	if(s<=x&&t>=y) return x-s+t-y+1;
	if(s<=x&&t<=x||s>=y&&t>=y) return t-s;
	if(s>x&&t<y) return min(s-x+y-t+1,t-s);
	if(s>=x&&s<=y&&t>=y) return min(t-y+1+s-x,t-s);
	if(s<=x&&t>=x&&t<=y) return min(x-s+1+y-t,t-s);
	return 0;
}

int main()
{
	scanf("%d%d%d",&n,&x,&y);
	if(x>y) swap(x,y);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			cnt[getdis(i,j)]++;
	for(int k=1;k<=n-1;k++)
		printf("%d\n",cnt[k]); 
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
 int R[MAX], n;

 cin >> n;
 for ( int i = 0; i < n; i++ ) cin >> R[i];

 int maxv = -2000000000; //
 int minv = R[0];

 for ( int i = 1; i < n; i++ ){
  maxv = max(maxv, R[i] - minv);
  minv = min(minv, R[i]);
 }

 cout << maxv << endl;

 return 0;
}



Measured memory_bytes: 3868
N, K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
    
h.sort()

ans = 10**9
for i in range(K-1, N):
    diff = h[i] - h[i-(K-1)]
    if diff < ans:
        ans = diff

print(ans)

Measured memory_bytes: 7484
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll n, a[20], b, c;
vector<vector<ll>> x(20), y(20); 

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	for(ll i = 0; i < n; i++){
		cin >> a[i];
		for(ll j = 0; j < a[i]; j++){
			cin >> b >> c;
			b--;
			x[i].pb(b), y[i].pb(c);
		}
	}
	ll ans = 0;
	for(ll i = 0; i < (1 << n); i++){
		ll cnt = 0, cek = 1;
		for(ll j = 0; j < n; j++){
			if(i & (1 << j)){
				cnt++;
				for(ll k = 0; k < a[j]; k++){
					if((i & (1ll << x[j][k]) && y[j][k])){
						continue;
					}
					else if((!(i & (1 << x[j][k])) && !(y[j][k]))){
						continue;
					}
					else{
						cek = 0;
						break;
					}
				}
			}
		}
		if(cek){
			ans = max(ans, cnt);
		}
	}
	cout << ans << '\n';				
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////





int main() {
	
	ll X;
	cin >> X;
	if (X == 3 || X == 5 || X == 7) { cout << "YES"; }
	else { cout << "NO"; }

	system("PAUSE");
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int INF = 1000000007;

    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int ans = X;

    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= D; j += A[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

void Max(dd &pos,dd val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(dd &pos,dd val){pos=min(pos,val);}

string str="RLUD";

vector<dd>tim;
void call(vector<dd>v[3]){
    rep(i,0,2){
        sort(v[i].begin(),v[i].end());
        reverse(v[i].begin(),v[i].end());
    }
    ll ma[3];
    rep(i,0,2)if(v[i].size()!=0)ma[i]=v[i][0];
    if(v[0].size()!=0&&v[1].size()!=0){
        tim.pb((ma[1]-ma[0])/2.0);
    }
    if(v[2].size()!=0&&v[1].size()!=0){
        tim.pb(ma[1]-ma[2]);
    }
    if(v[0].size()!=0&&v[2].size()!=0){
        tim.pb(ma[2]-ma[0]);
    }
}
void cal(vector<dd>v[3]){
    call(v);
    rep(i,0,2){
        if(v[i].size()==0)continue;
        rep(j,0,v[i].size()-1){
            v[i][j]*=-1;
        }
    }
    swap(v[0],v[1]);
    call(v);
}

int main(){fastio
    ll n;cin>>n;
    vector<l_l>v[4];
    rep(i,1,n){
        dd a,b;string s;
        cin>>a>>b>>s;
        rep(j,0,3){
            if(s[0]==str[j]){
                v[j].pb(d_d(a,b));
            }
        }
    }
    vector<dd>a[3],b[3];
    tim.pb(0);
    rep(i,0,1){
        ll k=i;
        for(auto p:v[i]){
            a[k].pb(p.fi);
            b[2].pb(p.se);
        }
    }
    rep(i,2,3){
        ll k=i-2;
        for(auto p:v[i]){
            a[2].pb(p.fi);
            b[k].pb(p.se);
        }
    }
    /*
    rep(i,0,2){
        cout<<i<<":";
        for(auto x:a[i])cout<<x<<" ";
        cout<<endl;
    }cout<<endl;
    rep(i,0,2){
        cout<<i<<":";
        for(auto x:b[i])cout<<x<<" ";
        cout<<endl;
    }cout<<endl;*/
    cal(a);
    cal(b);
    //for(auto x:tim)cout<<x<<endl;
    dd ans=1E17;
    for(auto t:tim){
        if(t<-0.2)continue;
        dd xb=-inf,xs=inf,yb=-inf,ys=inf;
        rep(i,0,3){
            for(auto p:v[i]){
                dd xp=p.fi;
                dd yp=p.se;
                if(i==0)xp+=t;
                else if(i==1)xp-=t;
                else if(i==2)yp+=t;
                else yp-=t;
                Max(xb,xp);Min(xs,xp);
                Max(yb,yp);Min(ys,yp);
            }
        }
        //cout<<t<<" "<<(yb-ys)*(xb-xs)<<endl;
        //cout<<yb<<" "<<ys<<" "<<xb<<" "<<xs<<endl;
        Min(ans,(yb-ys)*(xb-xs));
    }
    cout<<setprecision(20)<<ans<<endl;
    
    return 0;
}

/*
 
 3
 1 4 U
 2 3 U
 2 2 D
 */


Measured memory_bytes: 5664
#include <iostream>
#include <iomanip>

#define MAXN 2999

using namespace std;

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

    int n;
    long double p[MAXN+1];
    long double d[MAXN+1];

    cin >> n;
    for(int i=1 ; i<=n ; i++) cin >> p[i];
    for(int i=0 ; i<=n ; i++) d[i] = 0;

    d[0] = 1;
    d[1] = 0;
    for(int i=1 ; i<=n ; i++)
    {
        for(int j=i ; j>=1 ; j--)
        {
            d[j] = d[j-1] * p[i] + d[j] * (1 - p[i]);
        }
        d[0] = d[0] * (1 - p[i]);
    }

    long double ans = 0;
    for(int i=n/2+1 ; i<=n ; i++) ans += d[i];

    cout << fixed << setprecision(10) << ans;

    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, C, L):
    ans = sys.maxsize
    
    S = (A, B, C, 0)
    for l in product([0, 1, 2, 3], repeat=len(L)):
        
        
        ta = 0
        s = [A, B, C, 0]
        for i, f in enumerate(l):
            if s[f] != S[f] and f != 3:
                ta += 10
            s[f] -= L[i]
        if any([s[i] == S[i] for i in range(3)]):
            continue
        
        ta += sum([abs(s[i]) for i in range(3)])
        ans = min(ans, ta)

    return ans


def main():
    # N = read_int()
    N, A, B, C = read_int_n()
    L = [read_int() for _ in range(N)]
    print(slv(N, A, B, C, L))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6372
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))
    budget = 1000
    stock = 0

    for i in range(n-1):
        if A[i] < A[i+1] and A[i] <= budget:
            stock, budget = divmod(budget, A[i])
        elif A[i+1] < A[i]:
            budget += A[i]*stock
            stock = 0

    return str(A[-1]*stock+budget)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9208
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();

        if(a < b){
            if(b < c){
                System.out.printf("%d %d %d\n",a,b,c);
            }

            else if(a < c){
                System.out.printf("%d %d %d\n",a,c,b);
            }
            
            else{
                System.out.printf("%d %d %d\n",c,a,b);
            }

        }

        else{
            if(b > c){
                System.out.printf("%d %d %d\n",c,b,a); 
            }

            else if(a < c){
                System.out.printf("%d %d %d\n",b,a,c);
            }

            else{
                System.out.printf("%d %d %d\n",b,c,a);
            }

        }

        stdIn.close();

    }


}


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

using i64 = int64_t;

int main(){
    i64 R, G, B, N;
    cin >> R >> G >> B >> N;
    i64 ans = 0;
    for(i64 r=0;r<=N/R;++r){
        for(i64 g=0;g<=N/G;++g){
            i64 m = N - r*R - g*G;
            if(m < 0 || m%B != 0)continue;
            i64 b = m / B;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int y, m, d;
    cin >> y;
    cin.ignore();
    cin >> m;
    cin.ignore();
    cin >> d;

    if (m >= 5)
    {
        cout << "TBD" << endl;
    }
    else
    {
        cout << "Heisei" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappush, heappop
n = int(input())
L = [int(i) for i in input().split()]
heapify(L)
for i in range(n-1):
    a= heappop(L)
    b= heappop(L)
    s=(a+b)/2
    heappush(L,s)
print(s)

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<vector<int>>>> vvvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<vector<vector<vector<ll>>>> vvvvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;

int M,D,N,E;

int main() {
  cin >> M >> D >> N >> E;
  if(E == 1){
    cout << 1 <<endl;
  }
  else{
    cout << 0 <<endl;
  }
}

Measured memory_bytes: 256
using System;
class Program
{

    static void Main(string[] args)
    {

        // input with space delimiter
        string input = Console.ReadLine();
        var characters = input.ToCharArray();
        int n = input.Length;
        int cnt = 0;
        for ( int i = 0; i <= n/2-1; i++)
        {
            if (characters[i] != characters[n - i - 1])
                cnt++;
        }

        Console.WriteLine(cnt);

    }
}

Measured memory_bytes: 11220
#define N 5
#include <stdio.h>

int main(){
    
    int x[N];
    int y[N];
    int k;
    int i;
    
    for(i = 0; i < N; i++ ){
        scanf("%d",&x[i]);
    }
    scanf("%d",&k);

    if(x[4] - x[0] <= k)printf("Yay!\n");
    else printf(":(\n");
    
    return 0;
}

Measured memory_bytes: 128
// Try AtCoder
// author: Leonardone @ NEETSDKASU
package main

import "fmt"

func main() {
    var n, a, b int
    fmt.Scan(&n, &a, &b)
    min := (n - 1) * a + b
    max := a + (n - 1) * b
    ans := max - min + 1
    if ans < 0 {
        ans = 0
    }
    fmt.Println(ans)
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt(),b=sc.nextInt();//生地値段、トッピング値段
		int c=sc.nextInt();//生地カロリー
		int[] d=new int[n];//トッピングカロリー
		for(int i=0;i<n;i++){
			d[i]=sc.nextInt();
		}
		for(int i=0;i<d.length-1;i++){	//降順sort
            for(int j=0;j<d.length-i-1;j++){
            	if(d[j]<d[j+1]){
            		int s=d[j];
            		d[j]=d[j+1];
            		d[j+1]=s;
            	}
            }
		}
		int pt=0;
		int ans=0;
		int bp=0;
		for(int i=0;i<n;i++){
			pt+=d[i];
			bp=(c+pt)/(a+(i+1)*b);//1ドルあたりのカロリー数
			if(bp>ans)ans=bp;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 18108
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll dp[2009];
int x;
ll mod=1e9+7;
ll f(int sum)
{
    if (sum>x)
        return 0;
    if (sum==x)
        return 1;
    if (dp[sum]!=-1)
        return dp[sum];
    ll o=0;
    for (int j=3; j<=x; j++)
    {
        o=(o%mod+f(sum+j)%mod)%mod;
    }
    return dp[sum]=o;
}
int main()
{
    FASTINOUT;
    cin>>x;
    memset(dp,-1,sizeof dp);
    cout<<f(0);
    return 0;
}


Measured memory_bytes: 3692
def solve(n, tbl):
    ans = 0
    for i, row_i in enumerate(tbl):
        for j in range(i + 1, n):
            row_j = tbl[j]
            ij = row_i[j]
            mind = min((ik + kj for ik, kj in zip(row_i, row_j) if ik and kj), default=float('inf'))
            if ij > mind:
                return -1
            if ij < mind:
                ans += ij
    return ans


n = int(input())
tbl = [list(map(int, input().split())) for _ in range(n)]
print(solve(n, tbl))


Measured memory_bytes: 6644
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sz(a) (a).size()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
using namespace std;
using pii = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

int N, P;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> P;
  map<int, int> mp;
  int a = P;
  for (int i = 2; i*i <= P; i++) {
    while (a % i == 0) {
      mp[i]++;
      a /= i;
    }
  }  
  if (a != 1) mp[a]++;

  int ans = 1;
  for (auto v : mp) {
    int tmp = v.second / N;
    if (tmp == 0) continue;
    rep(i, 0, tmp) {
      ans *= v.first;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a+b==c || b+c==a || c+a==b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23124
///           _____                  _______                  _____                   _____
///          /\    \                /::\    \                /\    \                 /\    \
///         /::\    \              /::::\    \              /::\____\               /::\    \
///        /::::\    \            /::::::\    \            /:::/    /              /::::\    \
///       /::::::\    \          /::::::::\    \          /:::/    /              /::::::\    \
///      /:::/\:::\    \        /:::/~~\:::\    \        /:::/    /              /:::/\:::\    \
///     /:::/__\:::\    \      /:::/    \:::\    \      /:::/    /              /:::/__\:::\    \
///    /::::\   \:::\    \    /:::/    / \:::\    \    /:::/    /              /::::\   \:::\    \
///   /::::::\   \:::\    \  /:::/____/   \:::\____\  /:::/    /      _____   /::::::\   \:::\    \
///  /:::/\:::\   \:::\    \|:::|    |     |:::|    |/:::/____/      /\    \ /:::/\:::\   \:::\    \
/// /:::/  \:::\   \:::\____|:::|____|     |:::|____|:::|    /      /::\____/:::/  \:::\   \:::\____\
/// \::/    \:::\  /:::/    /\:::\   _\___/:::/    /|:::|____\     /:::/    \::/    \:::\  /:::/    /
///  \/____/ \:::\/:::/    /  \:::\ |::| /:::/    /  \:::\    \   /:::/    / \/____/ \:::\/:::/    /
///           \::::::/    /    \:::\|::|/:::/    /    \:::\    \ /:::/    /           \::::::/    /
///            \::::/    /      \::::::::::/    /      \:::\    /:::/    /             \::::/    /
///            /:::/    /        \::::::::/    /        \:::\__/:::/    /              /:::/    /
///           /:::/    /          \::::::/    /          \::::::::/    /              /:::/    /
///          /:::/    /            \::::/____/            \::::::/    /              /:::/    /
///         /:::/    /              |::|    |              \::::/    /              /:::/    /
///         \::/    /               |::|____|               \::/____/               \::/    /
///          \/____/                 ~~                      ~~                      \/____/
//I am aqua
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define speed  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo for(int i=0;i<n;i++) cin>>a[i];
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define l first
#define r second
#define input.txt ifstream fin("input.txt"); ofstream fout("output.txt");
using namespace std;
///--------------------------------------------------------------------------------------------------------------------

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

///--------------------------------------------------------------------------------------------------------------------
int main()
{
    int n;
    string s,t;
    cin>>n>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }
}
///I know that ;
///I know where I am
///Do not think I don't


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        for (int i = 0;; i++) {
            int tmp = x + i;
            if (sosu(tmp)) {
                System.out.println("" + tmp);
                break;
            }
        }
    }
    public static boolean sosu(int x) {
        for (int i = 2; i < x; i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 23764
#pragma GCC optimize("Ofast")
#include <stdio.h>
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
char buf[(1 << 22)], *p1 = buf, *p2 = buf;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int ab[(1<<22)];
int main(int argc, char *argv[])
{
	int n = read(),m = read();
	for (int i = 0; i < m; ++i) {
		int a = read(),b = read();
		if (*(ab+b) < a) {*(ab+b) = a;}
	}
	int ans = 0;
	int k = 1;
	for (int i = 1; i <= n; ++i) {
		if (k <= *(ab+i)) {
			k = i;
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  if(n == 1) {
    cout << 1 << endl;
  } else {
    ll l0 = 2;
    ll l1 = 1;
    ll ans;
    for(int i=0;i<n-1;i++) {
      ans = l0 + l1;
      l0 = l1;
      l1 = ans;
    }
    cout << ans << endl;
  }
}


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

int main(){
	char a='a',ch;
	int array[26]={};
	
	while(cin>>ch){
		if(isupper(ch)){
			ch=tolower(ch);
		}
		if(ch>='a'&&ch<='z'){
			array[ch-'a']++;	//ch-'a'でchのアルファベットに対応する番号がわかる
		}
	}
	for(int i=0;i<26;i++){
		cout<<a<<" : "<<array[i]<<endl;
		a++;
	}
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int e[20][20];
int v[33333];
int f[33333][20];
int n,m,ans;
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int x,y,v;
		scanf("%d%d%d",&x,&y,&v);
		e[--x][--y]=v; e[y][x]=v;
		ans+=v;
	}
	for (int i=0;i<1<<n;i++)
		for (int j=0;j<n;j++)
			if (i&(1<<j))
				for (int k=j+1;k<n;k++)
					if (i&(1<<k))
						v[i]+=e[j][k];
	memset(f,233,sizeof(f));
	for (int i=0;i<1<<n;i++)
		if (i&1) f[i][0]=v[i];
	for (int i=0;i<1<<n;i++)
		for (int j=0;j<n;j++)
			if (f[i][j]>=0){
				//printf("%d %d %d\n",i,j,f[i][j]);
				int res=(1<<n)-1-i;
				for (int ano=res;ano;ano=(ano-1)&res)
					for (int k=0;k<n;k++)
						if (e[j][k]&&!(i&(1<<k))&&(ano&(1<<k)))
							f[i|ano][k]=max(f[i|ano][k],f[i][j]+v[ano]+e[j][k]);
			}
	printf("%d\n",ans-f[(1<<n)-1][n-1]);
}

Measured memory_bytes: 2944
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(str(input().rstrip('\n'))).most_common()
    if len(s) == 2:
        for k, v in s:
            if v != 2:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(((a+b) == c) || ((a+c) == b) || ((b+c) == a)){
  cout << "Yes";
  }else{
  cout << "No";
  }
  cout << endl;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
flag = 0

for i in l:
  if i % 2 == 0:
    if (i % 3 == 0) or (i % 5 == 0):
      continue
    else:
      flag = 1
      break

print('DENIED' if flag == 1 else 'APPROVED')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000007;
const int N = 200006;
const ll INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    cout << (x == 0) << '\n';   
    return 0;
}

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

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	//freopen("input.txt","r",stdin);
    int n;
    cin>>n;
    (n%1000==0)?cout<<0<<"\n":cout<<(1000-(n%1000))<<"\n";
	return 0;
}


Measured memory_bytes: 3660
n=int(input())
h=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(n-1):
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
    if i+2<n:
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
print(dp[-1])

Measured memory_bytes: 20368
import sys
input = sys.stdin.readline

N, M, L = map(int, input().split())
INF = 10**18
G = [[INF]*N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    if c <= L:
        G[a][b] = c
        G[b][a] = c
for k in range(N):
    for i in range(N):
        for j in range(N):
            G[i][j] = min(G[i][j], G[i][k]+G[k][j])
G2 = [[INF]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        if G[i][j] <= L:
            G2[i][j] = 1
for k in range(N):
    for i in range(N):
        for j in range(N):
            G2[i][j] = min(G2[i][j], G2[i][k]+G2[k][j])
Q = int(input())
ans = []
for i in range(Q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    if G2[s][t] == INF:
        ans.append(-1)
    else:
        ans.append(G2[s][t]-1)
print(*ans, sep="\n")


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);

    ll n;
    cin >> n;
    string ss;
    set<string> s;
    rep(i, n){
        cin >> ss;
        s.insert(ss);
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 19272
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forab(i, a, b) for(int i=(int)a; i<=(int)b; ++i)
#define fornd(i, n) for(int i=n; i>=0; --i)

const int inf = (int)1e6+5;
const int nax = (int)3e5+5;

void compute(){
    int a, b, t; cin >> a>>b >> t;
    cout << floor((t+0.5)*1.0/(a*1.0))*b << "\n";
}
void compute2(){
    int n;
    cin >> n;
    vi v(n), c(n);
    forn(i, n){
        cin >> v[i];
    }
    forn(i, n){
        cin >> c[i];
        c[i] = v[i]-c[i];
    }
    int res = 0;
    forn(i, n){
        if(c[i] + res > res)
            res += c[i];
    }
    cout << res << "\n";
}
void compute3(){
    int n; cin >> n;
    vi v(n);
    forn(i, n){
        cin >> v[i];
    }
    int k = 0;
}

void compute4(){
    int n; cin >> n;
    vi v(n);
    vii absd(n);
    int pos = 0;
    forn(i, n){
        cin >> v[i];
        absd[i].first = (v[i] < 0) ? v[i]*(-1) : v[i];
        absd[i].second = i;
        if(v[i] > 0) ++pos;
    }
    sort(all(absd));
    ll res = 0;
    map<int, int> mp;
    forn(i, pos){
        res += absd[i].first;
        mp.insert(mkp(absd[i].second, i));
    }
    forn(i, n){
        auto it = mp.find(i);
        if(it == mp.end())
            res += v[i];
    }
    cout << res << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //    int t;
    //    cin>>t;
    //    while(t--)
    compute2();
    return 0;
}


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

int a[4], b[4];

int main() {
	while( cin >> a[0] ) {
		int i, j;
		for( i = 1; i < 4; i++ )
			cin >> a[i];
		for( i = 0; i < 4; i++ )
			cin >> b[i];
			
		int hit = 0, blow = 0;
		for( i = 0; i < 4; i++ )
			hit += (a[i] == b[i]);
		
		for( i = 0; i < 4; i++ ) {
			for( j = 0; j < 4; j++ ) {
				if ( a[i] == b[j] ) {
					break;
				}
			}
			blow += (j < 4);
		}
		blow -= hit;
		
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def eratosthenes(n):
 is_p=[1]*n
 p_list=[]

 is_p[0]=0
 is_p[1]=0

 for i in range(2,n):
  if is_p[i]:
   p_list.append(i)
   for j in range(i*i,n,i):
    is_p[j] = 0

 return is_p, p_list

lim=10**5+1
is_p, p_list=eratosthenes(lim)

q=int(input())

b=[0]
for i in range(1,lim+1):
 if is_p[i-1] and is_p[i//2]:
  b.append(b[i-1]+1)
 else:
  b.append(b[i-1])

import sys
stdin=sys.stdin
temp=lambda: list(map(int, stdin.readline().split()))

for i in range(q):
# l,r=map(int,input().split())
 l,r=temp()
 print(b[r+1]-b[l])

Measured memory_bytes: 5900
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << "\n"
#define pr2(a,b)cout << a <<  " " <<b<< "\n"
#define pr3(a,b,c) cout << a <<" " << b << " " << c << "\n"

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    gcd(b,a%b);
}
const int maxn = 2*1e5 + 10;
void solve(){

   int n,m;
   cin >> n >> m;

   int x = n%m;
   int ans = min(x, abs(x-m));

   cout << ans << endl;


} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define MAXN 10010
using namespace std;
int pre[MAXN];
int find(int x)
{
	return (pre[x] == x) ? x : pre[x] = find(pre[x]);
}
int main(void)
{
	int n, q;

	while (scanf("%d%d", &n, &q) != EOF)
	{
		bool op;
		int x, y;

		for (int i = 0; i < n; i++)pre[i] = i;
		for (int i = 0; i < q; i++)
		{
			scanf("%d%d%d", &op, &x, &y);
			x = find(x), y = find(y);
			if (op)printf("%d\n", x == y);
			else pre[x] = y;
		}
	}

	return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (int) 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    int ac = 0;
    int pena = 0;
    vector<bool> hasAC(n, false);
    vector<int> pastPena(n, 0);
    for (int i = 0; i < m; i++)
    {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            if (pastPena[p] && !hasAC[p]) {
                pena += pastPena[p];
                pastPena[p] = 0;
            }
            hasAC[p] = true;
        }
        else {
            pastPena[p]++;
        }
    }
    cout << accumulate(hasAC.begin(), hasAC.end(), 0) << " " << pena << "\n";
}

Measured memory_bytes: 640