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

public class Main {

	// 109-B
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String inputLine = sc.nextLine();
			int n = Integer.parseInt(inputLine);
			List<String> wordList = new ArrayList<String>(n);
			String lastWord = null;
			for(int i = 0; i < n; i++)
			{
				inputLine = sc.nextLine();
				if (lastWord != null && !inputLine.startsWith(lastWord))
				{
					System.out.println("No");
					return;
				}
				else if (wordList.indexOf(inputLine) != -1)
				{
					System.out.println("No");
					return;
				}
				else
				{
					lastWord = inputLine.substring(inputLine.length() - 1, inputLine.length());
					wordList.add(inputLine);
				}
			}
			System.out.println("Yes");

		} catch (Exception e) {
			System.out.println("Input Error");
		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 22612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CBraveForceStory solver = new CBraveForceStory();
        solver.solve(1, in, out);
        out.close();
    }

    static class CBraveForceStory {
        private static int[] DX = {1, 1, 0, -1, -1, 0};
        private static int[] DY = {0, 1, 1, 0, -1, -1};

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int t = in.nextInt(), n = in.nextInt();
            while (t != 0 || n != 0) {
                boolean[][] board = new boolean[200][200], visited = new boolean[200][200];
                for (int i = 0; i < n; i++) {
                    board[in.nextInt() + 100][in.nextInt() + 100] = true;
                }

                Queue<CBraveForceStory.Point> q = new ArrayDeque<>();
                CBraveForceStory.Point start = new CBraveForceStory.Point(in.nextInt() + 100, in.nextInt() + 100, 0);
                q.offer(start);
                visited[start.x][start.y] = true;

                while (!q.isEmpty()) {
                    CBraveForceStory.Point p = q.poll();
                    if (p.d < t) {
                        for (int i = 0; i < 6; i++) {
                            int nx = p.x + DX[i], ny = p.y + DY[i];
                            if (board[nx][ny] || visited[nx][ny]) continue;
                            visited[nx][ny] = true;
                            q.offer(new CBraveForceStory.Point(nx, ny, p.d + 1));
                        }
                    }
                }

                int ans = 0;
                for (int i = 0; i < 200; i++) {
                    for (int j = 0; j < 200; j++) {
                        if (visited[i][j]) ans++;
                    }
                }

                out.println(ans);
                t = in.nextInt();
                n = in.nextInt();
            }
        }

        private static class Point {
            int x;
            int y;
            int d;

            Point(int x, int y, int d) {
                this.x = x;
                this.y = y;
                this.d = d;
            }

        }

    }
}




Measured memory_bytes: 74312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
 
int main(){
    string s;
    cin>>s;
    int c0=0,c1=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0')c0++;
        else c1++;
    }
    cout<<2*min(c0,c1);
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define inf 0x3f3f3f
#define PI acos(-1.0)
using namespace std;

typedef long long ll;

struct node
{
    ll num;
}e[100000+10];

int main()
{
    int n;
    ll k;
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        e[a].num+=b;
    }
    for(int i=1;i<=1e5;i++)
    {
        if(e[i].num>=k)
        {
            cout << i << endl;
            return 0;
        }
        k-=e[i].num;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll n, dt[1000005], cur;

int main()
{
	scanf("%lld",&n);
	dt[0] = 1;
	dt[1] = n;
	dt[2] = n*n % mod;
	cur = 2*n-1;
	for(ll i=3;i<=n;i++) {
		cur += dt[i-1] - dt[i-2] + dt[i-3] - 1;
		cur = (cur%mod+mod)%mod;
		dt[i] = (cur + (n-1)*(n-1)) % mod;
	}
	printf("%lld\n",dt[n]);
}


Measured memory_bytes: 8064
# coding: utf-8
# Your code here!
import sys
n,k = [int(i) for i in input().split()]
s=input()

a = []
c = 0
now = 1
for ss in s:
    if str(now) == ss:
        c += 1
    else:
        now = 1 - now
        a.append(c)
        c=1
a.append(c)
if now == 0:
    a.append(0)

#print(s)
#print(a)

L = len(a)
ans = sum(a[0:2*k+1])
newans=ans
right = 2*k+2
while(right < L):
#    print(right,"r",ans, a[right],  a[right-1], a[right-2*k-1],  a[right-2*k-2])
    newans += a[right] + a[right-1]- a[right-2*k-1] - a[right-2*k-2]
    right += 2
#    print(newans)
    ans = max(ans,newans)
#print("ans")
print(ans)







Measured memory_bytes: 4468
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long  N,M;
    double meanTime,p;
    p = 1-1.0/(1<<M);
    meanTime = p/(1-p);
    cin >> N >> M;
    cout << ((N - M) * 100 + 1900 * M) * (1<<M) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	double sum = 0;
	for(int i = 0; i < n;i++){
		double a;
		cin>>a;
		sum+=(1.0/a);
	}
	cout<<1.0/sum<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0, a = 0, b = 0, ab = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s[0] == 'B' and s[s.size() - 1] == 'A') {
            ab++;
        } else {
            if (s[s.size() - 1] == 'A') {
                a++;
            }
            if (s[0] == 'B') {
                b++;
            }
        }
        for (int j = 0; j < s.size() - 1; j++) {
            if (s[j] == 'A' and s[j + 1] == 'B') {
                ans++;
            }
        }
    }

    if (ab > 0) {
        ans += ab - 1;
        if (a > 0 or b > 0) {
            ans++;
        }
    }
    ans += min(a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int ll;
typedef vector<int > vecint;
typedef vector<bool > vecbool;
typedef vector<string > vecstr;
int n, m, k;
vector<unordered_set<int>> fr;
vector<unordered_set<int>> nonfr;
vector<unordered_set<int>> tree;
vecint tmap;
void dfs(int i, int x){
  //loop for friend x
  for(auto itr = fr[x].begin(); itr!= fr[x].end();itr++){
    if(tmap[*itr] != -1)continue;
    tree[i].insert(*itr);
    tmap[*itr] = i;
    dfs(i, *itr);
  }
}
int main()
{
  cin >> n >> m >> k;
  ///////
  fr.resize(n + 1);
  nonfr.resize(n + 1);
  int a, b;
  REP(i,m){
    cin >> a >> b;
    fr[a].insert(b);
    fr[b].insert(a);
    nonfr[a].insert(b);
    nonfr[b].insert(a);
  }
  REP(i,k){
    cin >> a >> b;
    nonfr[a].insert(b);
    nonfr[b].insert(a);
  }
  tmap.resize(n + 1);
  fill(all(tmap), -1);
  ///////
  int ini = 1;
  int nt = 0;
  bool ok = false;
  while(!ok){
    tree.push_back(unordered_set<int >());
    tmap[ini] = nt;
    tree[nt].insert(ini);
    dfs(nt,ini);
    nt++;
    ok = true;
    for(int i = ini; i <= n; i++){
      if(tmap[i] == -1){
	ini = i;
	ok = false;
	break;
      }
    }
  }
  // for(int i = 0; i < tree.size(); i ++){
  //   cout << "tree "<<i << endl;
  //   for(auto itr = tree[i].begin(); itr != tree[i].end();itr++){
  //     cout << *itr << " ";
  //   }
  //   cout << endl;
  // }
  // for(int i = 1; i < nonfr.size(); i ++){
  //   cout << "nonfr "<<i << endl;
  //   for(auto itr = nonfr[i].begin(); itr != nonfr[i].end();itr++){
  //     cout << *itr << " ";
  //   }
  //   cout << endl;
  // }

  for(int i = 1; i <= n; i ++){
    int ans = 0;
    for(auto itr = nonfr[i].begin(); itr != nonfr[i].end(); itr++){
      if(tree[tmap[i]].find(*itr)!= tree[tmap[i]].end()) ans ++;
    }
    ans = tree[tmap[i]].size() - ans - 1;
    cout << ans <<" ";
  }
  cout << endl;
}



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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}






Measured memory_bytes: 3524
N, K = map(int,input().split())
list_b = []

for i in range(K):
    d = 0
    d = int(input())
    list_a = input().split()
    for i in range(len(list_a)):
        list_b.append(int(list_a[i]))
    list_a = []

a = set(list_b)
ans = N - len(a)
print(ans)


Measured memory_bytes: 9204
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

X=get_nsp
N=X.size


ans=0
l=0
r=N-1
N.times do|i|
    if X[i]=="T"
        ans+=1
    else
        l=i
        break
    end
end
N.times do|i|
    if X[N-1-i]=="S"
        ans+=1
    else
        r=N-1-i
        break
    end
end
x=X[l..r]
n=x.size
cnt_s=0
x.each do|c|
    if c=="S"
      cnt_s+=1
    else
      if cnt_s.zero?
          ans+=1
      else
          cnt_s-=1
      end
    end
end
puts ans+cnt_s

Measured memory_bytes: 31280
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
    int sign = 1;
    T ret = 0;
    char c;

    do{
        c = getc();
    }while(c == ' ' || c == '\n');
    if(c == '-')sign = -1;
    else ret = c-'0';
    while(1){
        c = getc();
        if(c < '0' || c > '9')break;
        ret = 10*ret + c-'0';
    }
    return sign * ret;
}

inline void ini(int& x){
    x = getnum<int>();
}

inline void scani(int& x){
    scanf("%d",&x);
}

//end of macro

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    int x;
    cin>>x;
    int mm = x * 360 / __gcd(x, 360);
    cout << mm / x << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<ll>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
#define repm(i, a, b) for(ll i = (ll)a; i > (ll)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<ll, vector<ll>, greater<ll> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	map<ll, ll> even;
	map<ll, ll> odd;
	vector<ll> tmp_v;
	rep(i, 0, n) {
		ll v;
		cin >> v;
		if(i % 2 == 0) even[v]++;
		else odd[v]++;
		tmp_v.push_back(v);
	}

	ll e1 = -1;
	ll e2 = -1;
	ll max_e1 = -1;
	ll max_e2 = -1;
	ll o1 = -1;
	ll o2 = -1;
	ll max_o1 = -1;
	ll max_o2 = -1;

	for(map<ll, ll>::iterator it = even.begin(); it != even.end(); it++) {
		if(max_e1 < it->second) {
			if(e2 != -1) {
				max_e2 = max_e1;
				e2 = e1;
			}
			e1 = it->first;
			max_e1 = it->second;
			continue;
		} 

		if(e2 != it->first and max_e2 < it->second) {
			e2 = it->first;
			max_e2 = it->second;
		}
	}

	for(map<ll, ll>::iterator it = odd.begin(); it != odd.end(); it++) {
		if(max_o1 < it->second) {
			if(o2 != -1) {
				max_o2 = max_o1;
				o2 = o1;
			}
			o1 = it->first;
			max_o1 = it->second;
			continue;
		} 

		if(o2 != it->first and max_o2 < it->second) {
			o2 = it->first;
			max_o2 = it->second;
		}
	}
	
	ll rsl1 = 0;
	ll rsl2 = 0;
	if(e1 != o1) {
		rep(i, 0, n) {
			if(i % 2 == 0) {
				if(e1 != tmp_v[i]) rsl1++;
			} else {
				if(o1 != tmp_v[i]) rsl1++;
			}
		}
		cout << rsl1 << endl;
	} else {
		rep(i, 0, n) {
			if(i % 2 == 0) {
				if(e1 != tmp_v[i]) rsl1++;
			} else {
				if(o2 != tmp_v[i]) rsl1++;
			}
		}
		rep(i, 0, n) {
			if(i % 2 == 0) {
				if(e2 != tmp_v[i]) rsl2++;
			} else {
				if(o1 != tmp_v[i]) rsl2++;
			}
		}
		ll rsl = min(rsl1, rsl2);
		cout << rsl << endl;
	}
}


Measured memory_bytes: 7284
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B, K;
    cin >> A >> B >> K;
    for(ll i = A; i <= B; i++) {
        if (i < A+K | B-K < i) print(i);
    }
    return 0;
}


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

int main(){
	long long a;
  	cin >> a;
  	float b;
  	cin >> b;
    ll p = b*100.00 + 0.5;
    a =  a *p;
  	a /= 100;
  	cout << a << endl;
}


Measured memory_bytes: 3684
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> matrix(H, vector<char>(W));
	rep(i, H) rep(j, W) cin >> matrix[i][j];

	vector<int> remove_h, remove_w;
	rep(i, H) {
		int cnt=0;
		rep(j, W) if (matrix[i][j]=='#') cnt++;
		if (cnt==0) remove_h.push_back(i);
	}
	rep(j, W) {
		int cnt=0;
		rep(i, H) if (matrix[i][j]=='#') cnt++;
		if (cnt==0) remove_w.push_back(j);
	}
	
	if (remove_h.size() || remove_w.size()) {
		rep(i, H) rep(j, W) {
			if (find(ALL(remove_h), i) != remove_h.end()) continue;
			if (find(ALL(remove_w), j) == remove_w.end()) cout << matrix[i][j];
			if (j==W-1) cout << endl;
		}
	} else {
		rep(i, H) rep(j, W) {
			cout << matrix[i][j];
			if (j==W-1) cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
	vector<int>in(5);
	int a,b;
	while(cin>>a>>b,a||b){
		in[0]=a+b;
		loop(i,1,5){
			cin>>a>>b;
			in[i]=a+b;
		}
		int maxi=0;
		rep(i,5)maxi=max(maxi,in[i]);
		rep(i,5)if(maxi==in[i])cout<<(char)('A'+i)<<" "<<in[i]<<endl;
	}
}

Measured memory_bytes: 1192
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  sort(a.rbegin(), a.rend(), [](auto &x, auto &y){return abs(x) < abs(y);});

  vector<ll> neg, pos;
  for (int i = 0; i < k; i++) {
    if (a[i] < 0) neg.push_back(a[i]);
    else if (a[i] > 0) pos.push_back(a[i]);
    else {
      cout << 0 << endl;
      return 0;
    }
  }
  if (neg.size() % 2 == 1) {
    ll next_neg = 0;
    bool next_neg_found = false;
    ll next_pos = 0;
    bool next_pos_found = false;
    for (int i = k; i < n; i++) {
      if (a[i] < 0) {
        next_neg = a[i];
        next_neg_found = true;
        break;
      }
    }
    for (int i = k; i < n; i++) {
      if (a[i] > 0) {
        next_pos = a[i];
        next_pos_found = true;
        break;
      }
    }
    if ((!next_neg_found && !next_pos_found) || (pos.size() == 0 && !next_pos_found)) {
      ll ans = 1;
      for (int i = n-1; i >= n - k; i--) {
        ans = (ans * a[i]) % mod;
        if (ans < 0) ans += mod;
      }
      cout << ans << endl;
      return 0;
    }
    else if (pos.size() == 0) {
      neg.pop_back();
      pos.push_back(next_pos);
    }
    else if (!next_neg_found) {
      neg.pop_back();
      pos.push_back(next_pos);
    }
    else if (!next_pos_found) {
      pos.pop_back();
      neg.push_back(next_neg);
    }
    else if (pos[pos.size()-1] * next_pos > neg[neg.size()-1] * next_neg) {
      neg.pop_back();
      pos.push_back(next_pos);
    }
    else {
      pos.pop_back();
      neg.push_back(next_neg);
    }
  }

  ll ans = 1;
  for (auto &x: pos) {
    ans = (ans * x) % mod;
  }
  for (auto &x: neg) {
    ans = (ans * x) % mod;
    if (ans < 0) ans += mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6864
def count6174(n):
    if n[0] == n[1] == n[2] == n[3]:
        return 'NA'
    count = 0
    while n != '6174':
        n = list(n)
        l = int(''.join(sorted(n, reverse=True)))
        s = int(''.join(sorted(n)))
        n = '{:04}'.format(l - s)
        count += 1
    return count

import sys
f = sys.stdin

while True:
    n = f.readline().strip()
    if n == '0000':
        break
    print(count6174(n))

Measured memory_bytes: 6740
N=int(input())
A=1
List=[]
while A<=N**(1/2):
  if N%A==0:
    List.append([A,int(N/A)])
  A+=1
Candidate=[]
for i in List:
  x=max(i)
  Candidate.append(len(str(x)))
print(min(Candidate))

Measured memory_bytes: 3188
int main(void) {
	int n, k, cnt, is_na;

	while (scanf("%d", &n), n) {
		cnt   = 1;
		is_na = 1; //bool????????¢???
		
		while (n--) {
			scanf("%d", &k);
			cnt   += k != 0; //??¨???0??\????????¨??¨????????°????¬?????????????
			is_na &= k <= 1; //??¨?¨?????????¨??????1??\????????¨?????????????????????????????§?????????
		}
		
		if (is_na) printf("NA\n");
		else	   printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 612
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int h, w;
	cin >> h >> w;
	vector<string> s(h);

	rep(y, h) {
		cin >> s[y];
	}
	vector<string> red = s, blue = s;

	rep(y, h)rep(x, w) {
		blue[y][x] = '#';
		red[y][x] = '.';
	}

	int y = 0, x = 0;
	int dr = 0;
	int sw = w, sh = h;
	int cnt = 0;

	while (1) {
		bool end = true;
		for (int i = 0;; i++) {
			if (s[y][x] == '.') {
				blue[y][x] = '.';
			}
			red[y][x] = '#';
			int ty = y + dy[dr], tx = x + dx[dr];
			int tty = ty + dy[dr], ttx = tx + dx[dr];
			if ((check(tx,ty,w,h) && red[ty][tx] == '#') || !check(ttx,tty,w,h) || (check(ttx, tty, w, h) && red[tty][ttx] == '#')) {
				break;
			}
			end = false;
			y = ty, x = tx;
		}
		if (end)break;
		dr = (dr + 1) % 4;
	}

	rep(y, h)rep(x, w) {
		if (s[y][x] == '#') {
			red[y][x] = '#';
		}
	}

	rep(y, h) {
		cout << red[y] << endl;
	}
	cout << endl;
	rep(y, h) {
		cout << blue[y] << endl;
	}

	return 0;
}

Measured memory_bytes: 1536
n,m=map(int,input().split())
mod=10**9+7
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0 for i in range(m+1)] for i in range(n+1)]
sum=[[0 for i in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,m+1):
    if s[i-1]==t[j-1]:
      dp[i][j]=(sum[i-1][j-1]+1)%mod
    else:dp[i][j]=0
    sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod
print((sum[-1][-1]+1)%mod)


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % 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 modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
bool ischar(char c){
	if('A'<=c&&c<='Z')return true;
	else return false;
}
signed main(){
	string s;
	cin>>s;
	rep(i,s.size())cout<<'x';
	cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long

int main(){
int a,b,c,k;
 std::cin >> a >> b >> c >> k;
 int max = std::max(a,std::max(b,c));
 int t=0;
 t = max;
 for(int i=1;i<=k;i++){
    t*=2;
 }
 if(max==a) std::cout << t+b+c;
 else if(max==b) std::cout << t+a+c;
 else if(max==c) std::cout << t+b+a;
 return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	multiset<int> se;
	se.insert(2e9);
	inc(i, n) {
		if(a[i] <= (*se.begin())) { se.insert(a[i]); } else {
			auto it = --(se.lower_bound(a[i]));
			se.erase(it);
			se.insert(a[i]);
		}
	}
	
	cout << SI(se) - 1 << endl;
	
	return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		long mod = N % K;
		System.out.println(mod <= K / 2 ? mod : K - mod);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
struct query{
  int type;//0=empty, 1=add-sum ,2=set-min
  ll value;
  query(int a=0,ll b=0):type(a),value(b) {}
};
 
 
#define SIZE (1<<17)
 
ll INF=(1LL<<60);
 
 
struct segtree{
  query s[SIZE*2];
  ll t[SIZE*2];// sum-add
  ll u[SIZE*2];// min-set
   
  void init(){
    for(int i=0;i<SIZE*2;i++){
      s[i]=query();
      t[i]=0;
      u[i]=0;
    }
  }
 
  void func(int k,int l,int r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }
 
  void compute(int k,int l,int r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    int m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }
 
  void Update(int a,int b,query x,int k=0,int l=0,int r=SIZE){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      int m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }
 
  ll Dfs(int type,int a,int b,int k=0,int l=0,int r=SIZE){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      int m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }
 
  ll Getsum(int a,int b){
    return Dfs(1,a,b);
  }
 
  ll Getmin(int a,int b){
    return Dfs(2,a,b);
  }
 
};
 
segtree T;
 
int main(){
  T.init();
   
  int n,q;
  scanf("%d %d",&n,&q);
  while(q--){
    int type,a,b,c;
    scanf("%d %d %d",&type,&a,&b);
    if(type==0){
      scanf("%d",&c);
      T.Update(a,b+1, query(2,c) );
    }else{
      printf("%lld\n", T.Getsum(a,b+1) );
    }
  }
  return 0;
}



Measured memory_bytes: 11400
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vpi vector<pair<int, int>>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define forn(i, x, y) for (int i = (int)x; i < (int)y; ++i)
#define rforn(i, x, y) for (int i = (int)x; i >= (int)y; --i)
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);                \
    cerr.tie(nullptr);
#define cases \
    int t;    \
    cin >> t; \
    while (t--)
// #define d long double
// #define ll long long
// #define ull unsigned long long

const int MOD = 1e9 + 7;

int gcd(int a, int b)
{
    return (b == 0 ? a : gcd(b, a % b));
}
int power(int x, int y)
{
    int ans = 1;

    while (y)
    {
        if (y & 1)
            ans = (ans * x) % MOD;

        y >>= 1;
        x = (x * x) % MOD;
    }
    return ans % MOD;
}

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int32_t main()
{
    IOS;
    int n = 5;
    int A[n];
    forn(i, 0, n)
    {
        cin >> A[i];
    }
    int small = 1e9;
    int dig;
    int in = 1e9;
    forn(i, 0, n)
    {
        dig = A[i] % 10;
        if (dig < small && dig != 0)
        {
            small = dig;
            in = i;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        if (i != in)
        {
            dig = A[i] % 10;
            if (dig != 0)
                A[i] += (10 - dig);
        }
    }
    cout << accumulate(A, A + n, 0) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int len,ans;
int main()
{
	
	cin>>s;
	len=s.length();
	for(int i=1;i<len;i++)
		if(s[i]!=s[i-1])ans++;
	cout<<ans;
    return 0;
}


Measured memory_bytes: 512
#人のすなるCounterなるものを我も書いてみんとてするなり
from collections import Counter

#方針 マイナスとプラスでDPを分割
iN,iA =[int(x) for x in input().split()]
aX = [int(x) - iA for x in input().split()]
aPlus = [x for x in aX if 0 < x ]
aMinus = [-1 * x for x in aX if x < 0  ]
iLenPlus = len(aPlus)
iLenMinus = len(aMinus)
iLen0 = iN - iLenPlus - iLenMinus
#0の場合はnCkの累積和なので別に計算する
#知ってたわけではなく解析しててみつけた
iCZero = 2**iLen0 - 1 #sum(k=1..N){nCk} = 2^n -1

iRet = 0
iRet += iCZero
iCZero += 1 #0の場合を追加

iUlim = min(sum(aPlus) , sum(aMinus))
if 0 < iUlim:
    dp1 = Counter([0,aPlus[0]])
    for i in range(1,iLenPlus):
        iThisX = aPlus[i]
        tmp = {}
        for k, v in dp1.items():
            tmp[iThisX + k] = v
        dp1 += tmp
    dp2 = Counter([0,aMinus[0]])
    for i in range(1,iLenMinus):
        iThisX = aMinus[i]
        tmp = {}
        for k, v in dp2.items():
            tmp[iThisX + k] = v
        dp2 += tmp
    for i in range(1,iUlim+1):
        iRet += iCZero * dp1[i] * dp2[i]
print(iRet)


Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

class Program
{
    static void Main(string[] args)
    {
        var wrong_answer = new wrong_answer();
        wrong_answer.Solve();
    }
}

public class wrong_answer
{
    const int INF = 1 << 29;
    const long INFL = 1L << 60;
    const int MOD = 1000000007;
    const int MOD2 = 998244353;

    myinout IO = new myinout();



    public void Solve()
    {

        var o = IO.intm;
        var n = o[0];
        var a = o[1];

        

        IO.wri((n+a-1)/a);
    }
}






public static class Math2
{
    public static long pow(long i, long n, long MOD = 1000000007)
    {
        long res = 1;
        while (n > 0)
        {
            if ((n & 1) != 0) res = res * i % MOD;
            i = i * i % MOD;
            n >>= 1;
        }
        return res;
    }

    public static long gcd(long i, long y)
    {
        while (y != 0)
        {
            var r = i % y;
            i = y;
            y = r;
        }
        return i;
    }

    public static long lcm(long i, long y)
    {
        return i * y / gcd(i, y);
    }

    public static BigInteger bgcd(BigInteger i, BigInteger y)
    {
        while (y != 0)
        {
            var r = i % y;
            i = y;
            y = r;
        }
        return i;
    }

    public static BigInteger blcm(BigInteger i, BigInteger y)
    {
        return i * y / bgcd(i, y);
    }

    public static Dictionary<long, int> primefactorization(long N)
    {

        var ret = new Dictionary<long, int>();

        for (long i = 2; i * i <= N; ++i)
        {
            int cnt = 0;
            while (N % i == 0)
            {
                cnt++;
                N /= i;
            }
            if (cnt != 0) ret[i] = cnt;

        }
        if (N >= 2) ret[N] = 1;

        return ret;

    }

    public static List<long> divisorenumrate(long N)
    {
        var ret = new List<long>();

        for (long i = 1; i * i <= N; ++i)
        {

            if (N % i == 0)
            {
                ret.Add(i);
                ret.Add(N / i);
            }

        }

        return ret;

    }

    public static void swap<T>(ref T a, ref T b)
    {
        var i = a;
        a = b;
        b = i;
    }

}

class myinout
{
    //in
    public string str => Console.ReadLine();

    public string[] strm => str.Split(' ');

    public long[] longm => strm.Select(long.Parse).ToArray();
    public int[] intm => strm.Select(int.Parse).ToArray();
    public char[] charm => str.ToArray();
    public double[] doublem => strm.Select(double.Parse).ToArray();
    public long long1 => longm[0];
    public int int1 => intm[0];
    public char char1 => charm[0];
    public double double1 => doublem[0];



    //out
    public void wri<T>(T i)
    {
        Console.WriteLine(i);
    }
    public void wri<T>(T[] i)
    {
        Console.WriteLine(string.Join(" ", i));
    }

    public void yn(bool i)
    {
        if (i) wri("Yes");
        else wri("No");
    }

}


Measured memory_bytes: 11348
a,b,k = map(int,input().split())
if k % 2 == 0:
    for i in range(k//2):
        if a % 2 != 0:
            a = a - 1
        b += a//2
        a = a//2
        if b % 2 != 0:
            b -= 1
        a += b // 2
        b = b // 2
else:
    k -= 1
    for i in range(k//2):
        if a % 2 != 0:
            a = a - 1
        b += a//2
        a = a//2
        if b % 2 != 0:
            b -= 1
        a += b // 2
        b = b // 2
    if a % 2 != 0:
        a = a - 1
    b += a//2
    a = a//2
print(a,end = ' ')
print(b)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a <= 1){ return 1; } else{ return a * fact(a - 1); } }
template<class T> inline ll comb(T a, T b){ return a == 0 ? 0 : fact(a) / fact(b) / fact(a - b); }

int main(){
    ll N;
    vector<ll> d;
    cin >> N;
    rep(i, 0, N){
        ll temp;
        cin >> temp;
        d.push_back(temp);
    }
    sort(begin(d), end(d));
    ll L, R;
    L = d[N / 2 - 1];
    R = d[N / 2];
    ll ans = R - L;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
int main()
{
	cin>>s;
	rep(i,s.size()-1)
	{
		if(s[i]=='A'&&s[i+1]=='C')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ull, ull> P; //ペア　タイプでふ
constexpr ll bigNum = 1000000007;

int main(void)
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    //ここから本体
    int N = 0;
    cin >> N;
    vector<string> vec(N);

    REP(i, N)
    {
        cin >> vec[i];
        sort(vec[i].begin(), vec[i].end());
    }

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

    ll count = 0;
    int tmp = 1;
    map<string, int> M;
    for (int i = 0; i < N; i++)
    {
        count += M[vec[i]];
        M[vec[i]]++;
    }
    cout << count;
}

Measured memory_bytes: 12032
import java.util.Scanner;
public class Main {
		
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int L = stdIn.nextInt();
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		int D = stdIn.nextInt();
		
		while(true) {
			boolean d = false;
			if(A > 0) {
				A -= C;
				d = true;
			}
			if(B > 0) {
				B -= D;
				d = true;
			}
			if(d) {
				L--;
			}
			else {
				break;
			}
		}
		System.out.println(L);
	}
}

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

int main(){

    int n, m; cin >> n >> m;
    set<int> sa, sb;
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        if(a == 1) sa.insert(b);
        if(b == n) sb.insert(a);
    }

    for(auto p : sa){
        if(sb.find(p) != sb.end()){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 9600
use std::io::*;
use std::str::FromStr;

const INF: i64 = 1e+14 as i64;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn select(moves: &mut Vec<usize>, aseq: &mut Vec<i64>, index: usize) {
    moves.push(index);
    // println!("{:?} {}", aseq, index);
    if index == 0 || index == aseq.len() - 1 {
        aseq.remove(index);
    } else {
        aseq[index] = aseq[index - 1] + aseq[index + 1];
        aseq.remove(index + 1);
        aseq.remove(index - 1);
    }
}

fn solve(n: usize, aseq: &Vec<i64>, offset: usize) -> (i64, Vec<usize>) {
    let mut ans = -INF;
    let mut moves = vec![];
    if n == 1 && offset == 1 { return (ans, moves); }
    {
        // all minus case
        let mut all_minus = true;
        let mut ans = -INF;
        let mut pos = 0;
        for i in 0..n {
            if i % 2 != offset { continue; }
            if aseq[i] > 0 { all_minus = false; }
            if ans < aseq[i] { 
                ans = aseq[i];
                pos = i;
            }
        }
        if all_minus {
            for i in (pos+1..n).rev() {
                moves.push(i);
            }
            for _ in 0..pos {
                moves.push(0);
            }
            return (ans, moves);
        }
    }
    ans = 0;
    for i in 0..n {
        if i % 2 != offset { continue; }
        if aseq[i] > 0 { ans += aseq[i]; }
    }
    let mut aseq = aseq.clone();
    if offset == 1 {
        select(&mut moves, &mut aseq, 0)
    }
    if aseq.len() % 2 != 1 {
        let index = aseq.len() - 1;
        select(&mut moves, &mut aseq, index);
    }
    while *aseq.first().unwrap() < 0 {
        select(&mut moves, &mut aseq, 0);
        select(&mut moves, &mut aseq, 0);
    }
    while *aseq.last().unwrap() < 0 {
        let index = aseq.len() - 1;
        select(&mut moves, &mut aseq, index);
        select(&mut moves, &mut aseq, index - 1);
    }
    while aseq.len() != 1 {
        assert!(aseq.len() >= 3);
        if aseq[2] > 0 {
            select(&mut moves, &mut aseq, 1);
        } else {
            assert!(aseq.len() >= 5);
            select(&mut moves, &mut aseq, 2);
        }
    }
    return (ans, moves);
}

fn print_ans(ans: (i64, Vec<usize>)) {
    println!("{}", ans.0);
    println!("{}", ans.1.len());
    for v in ans.1 {
        println!("{}", v + 1);
    }
}

fn main() {
    let n: usize = read();
    let mut aseq: Vec<i64> = vec![0; n];
    for i in 0..n {
        aseq[i] = read();
    }
    let ans0 = solve(n, &aseq, 0);
    let ans1 = solve(n, &aseq, 1);
    print_ans(if ans0.0 > ans1.0 { ans0 } else { ans1 });
}

Measured memory_bytes: 4352
n = int(input())
A = list(map(int, input().split()))
count = 0
def Merge(A, left, mid, right):
    global count
    L = A[left:mid]+[10**9]
    R = A[mid:right]+[10**9]

    i = 0
    j = 0

    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def MergeSort(A, left, right):
    if left+1 < right:
        mid = (left+right)//2
        MergeSort(A, left, mid)
        MergeSort(A, mid, right)
        Merge(A, left, mid, right)

MergeSort(A, 0, n)
print(' '.join([str(_) for _ in A]))
print(count)




Measured memory_bytes: 66852
/**
 * @author torith
 * @date 2018-11-01
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    int N; ll x;cin >> N >> x;
    ll sum = 0;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll t; cin >> t;
        sum += t;
        if (i > 0) {
            if(sum > x) {
                ans += sum - x;
                sum = max((ll) 0, t - sum + x);
            }else{
                sum = t;
            }
        }
    }

    cout << ans << "\n";


    return 0;
}



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

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string s, t;
    int a, b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u){
        cout << a-1 << ' ' << b << endl;
    }else{
        cout << a << ' ' << b-1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;
int g[4];
signed main(){
  rep(i,3){
    int a,b;cin>>a>>b;a--;b--;
    g[a]++,g[b]++;
  }
  if((g[0]*g[1]*g[2]*g[3])%2==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<long long int>can;
    can.push_back(a*c);
    can.push_back(a*d);
    can.push_back(b*c);
    can.push_back(b*d);
    cout<<*max_element(can.begin(),can.end());
       
    
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
  int tate,yoko,lot[31];
  cin >> tate >> yoko;
  for(int i=1; i<=tate; i++)
    lot[i]=i;
  while(yoko-->0){
    int a,b,temp;
    char x;
    cin >> a >> x >> b;
    temp=lot[a];
    lot[a]=lot[b];
    lot[b]=temp;
  }
  for(int i=1; i<=tate; i++)
    cout << lot[i] << endl;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <unordered_map>

int main() {
	int32_t n, displayed;
	std::cin >> n >> displayed;
	if(n >= 10)
		std::cout << displayed;
	else
		std::cout << displayed + 100 * (10 - n);
	return 0;
}




Measured memory_bytes: 256