akhauriyash/Code-Regression huggingface dataset:
#include <atcoder/mincostflow>
#include<bits/stdc++.h>
#define bascost 105
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace atcoder;

int main(){
  int n,m;
  cin >> n >> m;
  vector<string> s(64);
  int st=0,fi=(n*m+1);
  int cid=(fi+1);
  mcf_graph<int,int> g(n*m+133);
  for(int i=0;i<n;i++){
    cin >> s[i];
    s[i]+='#';
  }
  for(int i=0;i<m;i++){
    s[n]+='#';
  }
  int cc=0,ec=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      g.add_edge(i*m+j+1,fi,1,0);ec++;
      //printf("%d -> %d : %d\n",i*m+j+1,fi,0);
      if(s[i][j]=='o'){
        cc++;
        vector<int> fl(n*m,0);
        g.add_edge(st,cid,1,0);ec++;
        //printf("%d -> %d : %d\n",st,cid,0);
        queue<pair<int,int>> qu;
        qu.push(make_pair(i,j));
        vector<pair<int,int>> mem;
        while(!qu.empty()){
          pair<int,int> cp=qu.front();
          qu.pop();
          int cx=cp.first;
          int cy=cp.second;
          //printf("%d %d,%d\n",cid,cx,cy);
          if(fl[cx*m+cy]==1){continue;}
          if(fl[cx*m+cy]==0){
            //g.add_edge(cid,cx*m+cy+1,1,bascost+(i-cx)+(j-cy));
            mem.push_back(make_pair(bascost+(i-cx)+(j-cy),cx*m+cy+1));
            //printf("%d -> %d : %d\n",cid,cx*m+cy+1,(i-cx)+(j-cy));
          }
          fl[cx*m+cy]=1;
          if(s[cx+1][cy]!='#'){
            qu.push(make_pair(cx+1,cy));
          }
          if(s[cx][cy+1]!='#'){
            qu.push(make_pair(cx,cy+1));
          }
        }
        sort(mem.begin(),mem.end());
        int siz=mem.size();
        siz=min(siz,100);
        for(int ms=0;ms<siz;ms++){
          g.add_edge(cid,mem[ms].second,1,mem[ms].first);ec++;
        }
        cid++;
      }
    }
  }
  //cerr << ec << '\n';
  pair<int,int> result = g.flow(st,fi,cc);
  cout << -1*(result.second-bascost*cc) << '\n';
  return 0;
}


Measured memory_bytes: 4320
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()
#define ITE(c) typeof((c).begin())

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

using namespace std;

int main(){
	int n, r, p, c;
	vector<int> ls;
	while(cin>>n>>r&&n||r){
		ls.clear();
		for(int i=n;i>0;i--){
			ls.push_back(i);
		}
			
		rep(j,r){
			cin>>p>>c;
			vector<int> tmp;
			for(int i=p-1;i<p+c-1;i++){
				tmp.pb(ls.at(i));
			}
			ls.erase(ls.begin()+p-1,ls.begin()+p+c-1);
			EACH(i,ls){
				tmp.pb((*i));
			}
			ls.clear();
			EACH(i,tmp){
				ls.push_back((*i));
			}
		}
		cout<<ls.at(0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i + k - 1 < n; i++) {
			if (arr[i] < 0) {
				if (arr[i + k - 1] < 0) {
					min = Math.min(min, -arr[i]);
				} else {
					min = Math.min(min, Math.min(-arr[i] * 2 + arr[i + k - 1], -arr[i] + arr[i + k - 1] * 2));
				}
			} else {
				min = Math.min(min, arr[i + k - 1]);
			}
		}
		System.out.println(min);
	}
}


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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long A, long long B, std::vector<long long> X){
  ll ans = 0;
  for(ll i=0; i+1<N; i++) {
    if(A*(X[i+1]-X[i])<B)
      ans += A*(X[i+1]-X[i]);
    else
      ans += B;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  std::vector<long long> X(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&X[i]);
  }
  solve(N, A, B, std::move(X));
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, t, c;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  c = 1;
  t = vec.at(0);
  for (int i = 1; i < n; i++) {
    if(vec.at(i) >= t){
      c++;
      t = vec.at(i);
    }
  }
  cout << c << endl;
}
    



Measured memory_bytes: 256
N = int(input())

maxcount = -1
maxi = 0
for i in range(1, N+1):
  count = 0
  cur_i = i
  while True:
    if i % 2 == 0:
      i = i // 2
      count += 1
    else:
      break
  if count > maxcount:
    maxcount = count
    maxi = cur_i
print(maxi)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if(s.at(0) != 'A')
    {
        cout << "WA" << endl;
        return 0;
    }
    if(s.at(1) == 'C' || (int)s.at(1) < 97 )
    {
        cout << "WA";
        return 0;
    }
    int c_count = 0;
    for(int i = 2; i < s.length() -1; i++)
    {
        if(s.at(i) == 'C')
            c_count += 1;
        else if((int)s.at(i) < 97)
        {
            cout << "WA";
            return 0;
        }
    }
    if(c_count != 1)
    {
        cout << "WA";
        return 0;
    }
    if((int)s.at(s.length() -1) < 97)
    {
        cout << "WA";
        return 0;
    }
    cout << "AC";
    return 0;
}

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

int main() {
  int64_t A, B, N, x, ans;
  cin >> A >> B >> N;
  x = min(B-1,N);
  ans = (A*x)/B - (A*(x/B));
  
  cout << ans;
}

Measured memory_bytes: 3528
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;

int main(){
  int n,m,c;
  cin>>n>>m>>c;
  int b[30],a[30];
  int count=0,sum=0;
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++,sum=0){
    for(int k=0;k<m;k++){
      cin>>a[k];
      sum+=a[k]*b[k];
    }
    sum+=c;
    if(sum>0) count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string s[20];
    int count = 0;
    while(true){
        cin >> s[count];
        if(s[count] == "0")break;
        count++;
    }
    for(int i = 0; i < count; i++){
        string r = s[i];
        int a = 0, b = 0;
        for(int j = 1; j < r.size(); j++){
            if(r[j] == 'A')a++;
            else if(r[j] == 'B') b++;
 
        }
        if(a > b)a++;
        else b++;
        cout << a << " " << b << endl;
    }
    return 0;
}


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

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

using namespace std;

void init();
void solve();

int main()
{
	init();
	solve();
}

int W, H, N;
int xs, xe;
int ys, ye;

void init()
{
	cin >> W >> H >> N;
	xs = 0;
	ys = 0;
	xe = W;
	ye = H;
}

void update(int x, int y, int a)
{
	if (a == 1) {
		xs = max(xs, x);
	}
	if (a == 2) {
		xe= min(xe, x);
	}
	if (a == 3) {
		ys = max(ys, y);
	}
	if (a == 4) {
		ye = min(ye, y);
	}
}

void solve()
{
	rep(i, N) {
		int x, y, a;
		cin >> x >> y >> a;
		update(x, y, a);
	}
	cerr << xs << " " << xe << endl;
	cerr << ys << " " << ye << endl;
	if (xs > xe || ys > ye) cout << 0 << endl;
	else cout << (xe - xs) * (ye - ys) << endl; 
}

Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    int cnt=0;
    int ans=0;
    if(n%2==0)n-=1;
    for(int i=1;i<=n;i+=2){
        for(int j=1;j<=i;j++){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
        
        cnt=0;
    }
    out(ans);
    return 0;
}




Measured memory_bytes: 256
// https://atcoder.jp/contests/abc151/tasks/abc151_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, AC = 0, WA = 0;
    cin >> N >> M;
    unordered_set<int> st;
    vector<int> temp_wa(N);
    REP(i, M) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            if (st.count(p) == 0) {
                st.insert(p);
                AC++;
                WA += temp_wa[p];
            }
        } else {
            if (st.count(p) == 0) {
                temp_wa[p]++;
            }
        }
    }
    cout << AC << " " << WA << endl;

    return 0;
}


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

typedef long long LL;
typedef double DB;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

const int MOD   = 1e9+7;
const int MAXN  = 1010;

int have[1006];

int main() {
#ifdef LOCAL
    freopen("sample.in","r",stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    int sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>have[i];
        sum+=have[i];
    }
    if(sum%10==0)
    {
        sort(have,have+n);
        for(int i=0;i<n;i++)
        {
            if(have[i]%10)
            {
                sum-=have[i];
                break;
            }
        }
        if(sum%10==0)
            cout<<0<<endl;
        else 
            cout<<sum<<endl;
    }
    else
        cout<<sum<<endl;

    return 0;
}



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

int main()
{
  string s;
  cin >> s;
  int a, z;
  for(int i = 0; i < s.size(); i++)
    if(s[i] == 'A'){
      a = i;
      break;
    }
  for(int i = s.size()-1; i >= 0; i--)
    if(s[i] == 'Z'){
      z = i;
      break;
    }
  cout << z - a + 1 << endl;
}

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

int main(){
	int a , b , c , tmp;
	cin >> a >> b >> c ;
	if(b < a){ 
		tmp = a;
		a = b;
		b = tmp;
	}
	if(c < a){
		tmp = b;
		b = a;
		a = c;
		c = tmp;
	}else if(c < b){
		tmp = b;
		b = c;
		c = tmp;
	}
	
	cout << a << " " << b << " " << c << endl;
	
	return 0;
} 

Measured memory_bytes: 1164
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void ioup() { cin.tie(0); ios::sync_with_stdio(false); }

int n, a[100001];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (i + 1 == a[i]) {
			if (i < n - 1 && i + 2 == a[i + 1])
				swap(a[i], a[i + 1]);
			else if (i > 0 && i == a[i - 1])
				swap(a[i], a[i - 1]);
			else if (i > 0)
				swap(a[i], a[i - 1]);
			else if (i < n - 1)
				swap(a[i], a[i + 1]);
				
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        ll dist = x * x + y * y;
        if (d * d >= dist) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret ++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)



int main() {
	LL n;
	cin >> n;
	cout << (n % (d_sum(n))==0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
//         ONLY FOR KING RAHMANI MASTER OF DP       \\

#include <bits/stdc++.h>
#define int long long
#define lb(a) ((a)&(-a))
using namespace std;

const int maxn=4e2+11;

int n,a[maxn],dp[maxn][maxn],sum[maxn];

int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
   // cout<<setprecision(9);
   // cout<<std::fixed;
 //   ifstream cin("input.txt");
 //   ofstream cout("output.txt");
    cin>>n;
    for(int i=1;i<=n;i++){
       // scanf("%d",&(a[i]));
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
        dp[i][i]=0;
    }
    for(int j=1;j<n;j++)
    {
        for(int i=1;i+j<=n;i++)
        {
            dp[i][i+j]=1e18;
            for(int r=i;r<i+j;r++)
            {
                dp[i][i+j]=min(dp[i][i+j],dp[i][r]+dp[r+1][i+j]+sum[i+j]-sum[i-1]);
            }
        }
    }
    cout<<dp[1][n];
	return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;
    string s, t; cin >> s >> t;

    int m = 0;

    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == t[0]) {
            int p = 0;
            bool ok = true;

            while (i + p < s.size()) {
                if (s[i+p] != t[p]) {
                    ok = false;
                    break;
                }
                ++p;
            }

            if (ok) {
                m = max(m, p);
            }
        }
    }

    cout << 2 * n - m << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.Split.Int;
            var N = line[0];
            var L = line[1];

            var sum = L * N + (N - 1) * N / 2;
            var max = L + N - 1;
            if (max < 0)
                return sum - max;
            else if (L < 0)
                return sum;
            else
                return sum - L;
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> SplitString { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

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

int main(){
  int n, k;

  while(cin >> n >> k, !(n==0 && k==0)){
    int map[n][n];
    int inf = 1000000 * n;

    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        if(i == j) map[i][j] = 0;
        else       map[i][j] = inf;
      }
    }

    int flag;
    for(int i = 0; i < k; i++){
      cin >> flag;
      if(flag == 1){
        int c, d, e;
        cin >> c >> d >> e;
        c--; d--;
        if(map[c][d] < e){
          //do nothing
        }else{
          for(int j = 0; j < n-1; j++){
            for(int k = j+1; k < n; k++){
              int dist = min(map[j][c]+e+map[d][k] , map[j][d]+e+map[c][k]);
              if(map[j][k] > dist){
                map[j][k] = dist;
                map[k][j] = dist;
              }
            }
          }
        }
      }else{
        int a, b;
        cin >> a >> b;
        a--; b--;
        cout << (map[a][b]==inf ? -1 : map[a][b]) << endl;
      }
    }
  }
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> city(N);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        city.at(a - 1)++;
        city.at(b - 1)++;
    }

    for (int i = 0; i < N; i++) {
        cout << city.at(i) << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long LL;

int main()
{ 
    LL n;
    cin>>n;
    if(n%10==3){cout<<"bon"<<endl;}
    else if(n%10==0||n%10==1||n%10==6||n%10==8){cout<<"pon"<<endl;}
    else{cout<<"hon"<<endl;}
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define mod 1000000007
#define pii pair<int,int>
using namespace std;
long long dp1[1000][1000];
char a[1000][1000];
long long dp(int i,int j,int h,int w){
	if(j>=w||i>=h||a[i][j]=='#')return 0;
	if(j==w-1&&i==h-1)return 1;
	if(dp1[i][j]!=-1)return dp1[i][j];
	return dp1[i][j]=(dp(i+1,j,h,w)+dp(i,j+1,h,w))%mod;
}
int main()
{
	int h,w;
	cin>>h>>w;
	memset(dp1,-1,sizeof(dp1));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	cout<<(dp(0,0,h,w))%mod;
    return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool match(string s,string t,int i)
{
	bool ok=true;
	rep(j,t.size())
		ok&=s[i+j]=='?'||s[i+j]==t[j];
	return ok;
}

string solve(string s,string t)
{
	set<string> res;
	for(int i=0;i+t.size()<=s.size();i++)
		if(match(s,t,i)){
			string u=s;
			u.replace(i,t.size(),t);
			for(char& c:u) if(c=='?') c='a';
			res.insert(u);
		}
	return res.empty()?"UNRESTORABLE":*begin(res);
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(string s,t;cin>>s>>t;){
		cout<<solve(s,t)<<endl;
	}
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    ll T = 1, A = 1;
    for (int i = 0; i < N; i++) {
        ll t, a;
        cin >> t >> a;
        ll tt = (T + t - 1) / t;
        ll aa = (A + a - 1) / a;
        ll m = max(tt, aa);
        T = m * t;
        A = m * a;
    }
    cout << T + A << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[222222],b;
int main()
{
	int n,i;
	long long ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]-=i;
	}
	sort(a+1,a+n+1);
	b=a[(n+1)/2];
	for(i=1;i<=n;i++)
	{
		ans+=abs(a[i]-b);
	}
	printf("%lld\n",ans);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 300010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define db(x) cout << x << endl;
const int mod = 10e8+7;
const int eps = 1e-6;
using namespace std;
int a[maxn],b[maxn];
char s[maxn];
int c[maxn],si[maxn];
signed main()
{
	ios::sync_with_stdio(0);
	int k;
	cin >> k >> s;
	if(k >= strlen(s))
		cout << s;
	else
	{
		for(int i=0;i<k;i++)
			cout << s[i];
		cout << "...";
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
#define unrep(i,n) for(int i = n - 1; i >= 0; i--)
using namespace std;
int main(){
  long long n,k;
  cin >> n >> k;
  if(n <= k){
    cout << min(k-n, n) << endl;
    return 0;
  }
  long long s = n / k;
  long long temp = min(n-k*s, k*(s+1)-n);
  cout << temp << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			if (a <= 8 && b <= 8) {
				Console.WriteLine("Yay!");
			} else {
				Console.WriteLine(":(");
			}

		}
	}
}


Measured memory_bytes: 28288
#include<iostream>
using namespace std;
int main(){
	int a,b;
	while(true){cin >>a>>b;
	if(a==0 && b==0)
		break;
	if(a>b)
	{	int c=a;a=b;b=c;
	}
	cout <<a<<" "<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 2984
import sys
from heapq import heappop,heappush
input = sys.stdin.readline
n,Q = map(int,input().split())
stx = [list(map(int,input().split())) for i in range(n)]
dls = [int(input()) for i in range(Q)]
event = []
for i in range(n):
  s,t,x = stx[i]
  event.append((s-x,1,x))
  event.append((t-x,-1,x))
for i in range(Q):
  d = dls[i]
  event.append((d,2,i))
event.sort()
ans = [-1]*Q
s = set()
hq = []
for t,q,x in event:
  if q == 1:
    s.add(x)
    heappush(hq,x)
  elif q == -1:
    s.remove(x)
  elif q == 2:
    while hq and hq[0] not in s:
      heappop(hq)
    if hq:
      ans[x] = hq[0]
    else:
      ans[x] = -1
print(*ans,sep="\n")

Measured memory_bytes: 147988
#!/usr/bin/env python


def read():
    N, A, B = map(int, raw_input().split())
    posList = map(int, raw_input().split())
    return A, B, posList


def work((A, B, posList)):
    ans = 0
    for i in range(len(posList) - 1):
        ans += min(A * (posList[i + 1] - posList[i]), B)
    print ans


if __name__ == "__main__":
    work(read())


Measured memory_bytes: 11296
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    S = [str(input()) for i in range(N)]
    d = {}
    for i in S:
        if not(i in d):
            d[i] = 0
            #print(d)
    print(len(d))
if __name__ == '__main__':
    main()

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

int main(void) {
  int r;
  cin >> r;
  int x;
  char y = '1';
  while(y != '=') {
    cin >> y;
    if(y != '=') {
      cin >> x;
      if(y == '+') r += x;
      if(y == '-') r -= x;
      if(y == '*') r *= x;
      if(y == '/') r /= x;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 210;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 998244353;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


map<vi, ll> G;
map<vi, ll> F;

ll loopf(vector<int> vec);

ll loopg(vector<int> vec) {
	int n = sz(vec);
	if(G.find(vec) != G.end()) return G[vec];

	vector<vl> f(n + 1, vl(n + 1, 0));
	rep(i, 0, n) {
		rep(j, i + 1, n + 1) {
			if(i == 0 && j == n) continue;
			f[i][j] = loopf(vi(vec.begin() + i, vec.begin() + j));
		}
	}
	vl dp(n + 1, 0);
	dp[0] = 1;
	rep(i, 1, n + 1) {
		rep(j, 0, i) ADD(dp[i], dp[j] * f[j][i] % mod);
	}
	return G[vec] = (dp[n] + loopf(vec)) % mod;
}

ll loopf(vector<int> vec) {
	int n = sz(vec);
	if(n == 1) {
		if(vec[0] == 0) return 1;
		else return 2;
	}
	if(F.find(vec) != F.end()) return F[vec];

	ll ans = 0;
	rep(i, 1, n) {
		if(n % i) continue;
		vi res(i, 1);
		rep(j, 0, n) {
			res[j % i] &= vec[j];
		}
		ADD(ans, loopg(res));
	}
	return F[vec] = ans;
}

void solve() {
	string str;
	cin >> str;
	int n = sz(str);
	vector<int> vec(n);
	rep(i, 0, n) vec[i] = str[i] - '0';
	cout << loopg(vec) << "\n";
	// for(auto v : G) {
	// 	debug(v.fst, v.sec);
	// }
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

//constexpr auto MAX = 100100;

int solve(int val1, int val2)
{
	if (val1 % val2 == 0) return val2;
	else
	{
		int tmp = val1 % val2;

		solve(val2, tmp);
	}
}

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

	ll cnt = 0;
	ll sums = 0;
	ll tmp = INF;

	vector<ll> A(n);
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		sums += abs(A[i]);

		tmp = min(tmp, abs(A[i]));

		if (A[i] < 0) cnt++;
	}

	if (cnt % 2 == 0) cout << sums << endl;
	else cout << sums - (tmp * 2) << endl;

}

Measured memory_bytes: 1024
class BinaryTree():
    def __init__(self):
        self.root = None

    def insert(self, insert_node):
        p = None
        r = self.root
        while r:
            p = r
            if insert_node.value < r.value:
                r = r.left
            else:
                r = r.right

        if not p:
            self.root = insert_node
        elif insert_node.value < p.value:
            p.left = insert_node
        else:
            p.right = insert_node

    def find(self, find_value):
        r = self.root
        while r:
            if find_value == r.value:
                return "yes"
            if find_value < r.value:
                r = r.left
            else:
                r = r.right
        return "no"

    def delete(self, delete_value):
        flag = None
        p = None
        r = self.root
        while True:
            if delete_value == r.value:
                if r.left == None and r.right == None:
                    if flag == "l":
                        p.left = None
                    else:
                        p.right = None
                    return
                elif r.left == None:
                    if flag == "l":
                        p.left = r.right
                    else:
                        p.right = r.right
                    return
                elif r.right == None:
                    if flag == "l":
                        p.left = r.left
                    else:
                        p.right = r.left
                    return
                else:
                    min_node = r.right
                    while min_node:
                        p = min_node
                        min_node = min_node.left
                    swap_value = p.value
                    self.delete(swap_value)
                    r.value = swap_value
                    return
            elif delete_value < r.value:
                p = r
                r = r.left
                flag = "l"
            else:
                p = r
                r = r.right
                flag = "r"

class Node():
    def __init__(self, value, left, right):
        self.value = value
        self.left  = left
        self.right = right

    def pre_order_search(self):
        l = self.left
        r = self.right
        print("",self.value, end="")
        if l:
            l.pre_order_search()
        if r:
            r.pre_order_search()

    def in_order_search(self):
        l = self.left
        r = self.right
        if l:
            l.in_order_search()
        print("",self.value, end="")
        if r:
            r.in_order_search()

m = int(input())
tree = BinaryTree()

for i in range(m):
    inp = input().split()
    if inp[0] == "insert":
        tree.insert(Node(int(inp[1]), None, None))
    elif inp[0] == "find":
        print(tree.find(int(inp[1])))
    elif inp[0] == "delete":
        tree.delete(int(inp[1]))
    else:
        tree.root.in_order_search()
        print()
        tree.root.pre_order_search()
        print()

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int V, E;
vector<vector<int>> G;
vector<int> in_deg;
vector<bool> done;

bool solve()
{
    priority_queue<int, vector<int>, greater<int>> Q;

    rep(i, V) {
        if (in_deg[i] == 0) Q.push(i);
    }

    while (Q.size()) {
        int v = Q.top(); Q.pop();
        done[v] = true;

        for (int u : G[v]) {
            if (--in_deg[u] == 0) Q.push(u);
        }
    }

    rep(i, V) {
        if (in_deg[i] > 0) return true;
    }
    
    return false;
}

int main()
{
    cin >> V >> E;
    G.resize(V);
    in_deg.resize(V);
    done.resize(V);

    rep(i, E) {
        int S, T;
        cin >> S >> T;
        G[S].push_back(T);
        in_deg[T]++;
    }

    cout << solve() << endl;
}

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

int main() {
  int A, B, C, X, count = 0;
  cin >> A >> B >> C >> X;

  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
ks = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
  ks[i].pop(0)
p = list(map(int,input().split()))

ans = 0

for i in range(2**N):
  clear_flag = 1
  for j in range(M):
    tmp = 0
    for k in ks[j]:
      k -= 1
      if (i>>k) & 1:
        tmp += 1
    if tmp % 2 != p[j]:
      clear_flag = 0
      break
  if clear_flag == 1:
    ans += 1

print(ans)
        
  
    

Measured memory_bytes: 9124
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define FS first
#define SC second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x,n) cout << fixed << setprecision(n) << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);AIN(ll,A,N);
  ll count = 0;
  while(true){
    REP(i,N){
      if(A[i]%2 == 0){
        A[i] = A[i] / 2;
      }else{
        goto OUT;
      }
    }
    count++;
  }
  OUT:
  OUT(count);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n,m;
	while(cin>>n>>m&&!(n==0&&m==0))
	{
		pair<int,int> a[20000],b[20000];
		REP(i,m)
		{
			int x,y,z;
			cin>>x>>y>>z;
			y-=1;z-=1;
			a[i] = make_pair(x,y);
			b[i] = make_pair(x,z);
		}
		sort(a,a+m);
		sort(b,b+m);
		
		bool inf[20000]={};
		inf[0]=true;
		
		int ans(1);
		REP(i,m){if(inf[a[i].second]&&!inf[b[i].second]){inf[b[i].second]=true;ans++;}}

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

Measured memory_bytes: 1500
n = int(input())
l = 0
r = n - 1
print(l)
s_l = str(input())
if s_l == 'Vacant':
    exit()
while abs(l - r) > 1:
    m = (l + r) // 2
    print(m)
    s_m = str(input())
    if s_m == 'Vacant':
        exit()
    else:
        if (m - l) % 2:
            if s_m != s_l:
                l = m
                s_l = s_m
            else:
                r = m
                s_r = s_m
        else:
            if s_m != s_l:
                r = m
                s_r = s_m
            else:
                l = m
                s_l = s_m
else:
    print(r)
    s = str(input())


Measured memory_bytes: 9140
#!/usr/bin/env python3
import sys
import fractions

def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    x = [abs(i - X) for i in x]
    if len(x) == 1:
        print(x[0])
        exit()
    
    ans = fractions.gcd(x[0], x[1])
    for i in range(2,N):
        ans = fractions.gcd(ans,x[i])

    print(ans)

if __name__ == '__main__':
    main()

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

double theta(int x, int y) {
    double h = sqrt(pow(x,2)+pow(y,2));
    double t = asin(y / h);
    if (x >= 0 && y >= 0)
        return t;
    else if (x < 0 && y >= 0)
        return M_PI - t;
    else if (x < 0 && y < 0)
        return M_PI - t;
    else
        return 2 * M_PI + t;
}

int hoge(double p1[2], double p2[2], double p3[2])
{
    double theta1 = theta(p2[0] - p1[0], p2[1] - p1[1]);
    double theta2 = theta(p3[0] - p1[0], p3[1] - p1[1]);

    if (0 <= theta1 && theta1 <= M_PI)
        if (theta1<=theta2 && theta2 <= theta1 + M_PI)
            return 1;
        else
            return -1;
    else
        if (theta1 <= theta2 || theta2 <= (theta1 - M_PI))
            return 1;
        else
            return -1;
}

int main(void) {
    double p[4][2];
    char c;
    while (cin >> p[0][0]>> c >> p[0][1]) {
        for (int i = 1; i < 4; ++i)
            cin >> c >>  p[i][0] >> c >> p[i][1];

        int sum = 0;
        for (int i = 0; i < 4; ++i)
            sum += hoge(p[i], p[(i+1)%4], p[(i+2)%4]);

        cout << ((sum==4 || sum==-4)? "YES" : "NO") << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
long long a[100001];
map<long long, bool> m;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << '\n';
		return 0;
	}
	else if (n == 2) {
		cout << max(a[0], a[1]) << '\n';
		return 0;
	}

	vector<long long> v;
	for (long long i = 1; i * i <= a[0]; i++) {
		if (a[0] % i == 0) {
			v.push_back(i);
			if (i != a[0] / i) {
				v.push_back(a[0] / i);
			}
		}
	}
	long long ans = -1;
	for (int i = 0; i < v.size(); i++) {
		int T = 0;
		for (int k = 1; k < n; k++) {
			if (a[k] % v[i] != 0) {
				T++;
			}
		}
		if (T <= 1) {
			ans = max(ans, v[i]);
		}
	}
	v.clear();
	for (long long i = 1; i * i <= a[1]; i++) {
		if (a[1] % i == 0) {
			v.push_back(i);
			if (i != a[1] / i) {
				v.push_back(a[1] / i);
			}
		}
	}
	for (int i = 0; i < v.size(); i++) {
		int T = 0;
		for (int k = 0; k < n; k++) {
			if (k == 1)continue;
			if (a[k] % v[i] != 0) {
				T++;
			}
		}
		if (T <= 1) {
			ans = max(ans, v[i]);
		}
	}
	cout << ans << '\n';





}



Measured memory_bytes: 1024
from collections import Counter

n = int(input())

def factorize(n):
    b = 2
    factor = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            factor.append(b)
        b += 1
    if n > 1:
        factor.append(n)
    return factor

f = factorize(n)
c = Counter(f)

a = 0
for v in c.values():
    i = 1
    while v >= i:
        v -= i
        i += 1
        a += 1

print(a)


Measured memory_bytes: 9468
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define pb push_back
using namespace std;

template<typename T>T gcd( T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
template<typename T>void out(T data){cout<<data<<endl;}

int main(){
  int a,b;
  cin>>a>>b;
  if(a<=b){
    out(a);
  }else{
    out(a-1);
  }
  return 0;
}


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

int main() {

    int n, a[2 * 100000];
    long long sum1 = 0, sum2 = 0, ans = 1e+17;

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum2 += a[i];
    }

    sum1 += a[0], sum2 -= a[0];
    for(int i = 1; i < n; i++) {
        ans = min(ans, abs(sum1 - sum2));
        sum1 += a[i], sum2 -= a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine();
        Map<String , Integer> m = new HashMap<String, Integer>();

        for (int i = 0 ; i < w.length() ; i++) {
            String s = w.substring(i, i + 1);
            if (m.containsKey(s)) {
                m.put(s, m.get(s) + 1);
            } else {
                m.put(s, 1);
            }
        }
        Iterator<Integer> i = m.values().iterator();
        while (i.hasNext()) {
            Integer a = i.next();
            if (a % 2 == 1) {
                System.out.println("No");
                return;
            }
        }


        System.out.println("Yes");
    }

}

Measured memory_bytes: 22868
while True:
	m, f, r = map(int, input().split())
	if m == -1 and f == -1 and r == -1:
		exit()
	sum = 0
	sum = m + f
	if m == -1 or f == -1:print('F')
	elif sum >=  80:print('A')
	elif sum >= 65:print('B')
	elif sum >= 50:print('C')
	elif sum >= 30:
		if r >= 50:
			print('C')
		else:
			print('D')
	else:
		print('F')


Measured memory_bytes: 5592
n = int(input())
l = list(map(int,input().split()))
count = 0
if l[0] == 1:
  l[1] = l[0]
  count += 1
for i in range(1,n):
  if l[i] == i+1:
    if i != n-1:
      if l[i+1] == i+2:
        l[i],l[i+1] = l[i+1],l[i]
    else:
      l[i] = l[i-1]
    count += 1
print(count)

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

int main() {
	string tmp;
	cin >> tmp;
	int ans = 0;
	if (tmp.size() % 2) {
		if (tmp[tmp.size() / 2] == '(' || tmp[tmp.size() / 2] == ')') ++ans;
	}
	for (int i = 0; i < tmp.size() / 2; ++i) {
		if (tmp[i] == 'i' || tmp[i] == 'w') {
			if (tmp[i] != tmp[tmp.size() - i - 1]) ++ans;
		}
		else if (tmp[i] == '(') {
			if (tmp[tmp.size() - i - 1] != ')') ++ans;
		}
		else {
			if (tmp[tmp.size() - i - 1] != '(') ++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3192
#include <iostream>
using namespace std;
 
int main() {
	int N, a;
	cin >> N;
	int res = 0;
	for (int i = 1; i <= N; i++){
		cin >> a;
		if ((i % 2)&&(a % 2)) res++;
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3592