akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    ll n;
    cin>>n;
    string ans;
    while(n){
        int rem = n%26;
        if(rem==0)
            rem=26;
        ans = char(rem+'a'-1)+ans;
        n--;
        n/=26;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 3568
def str10to3(x):
    a = ""
    while x >= 3:
        a += str(x % 3)
        x = x / 3
    a += str(x % 3)
    return "".join(reversed(a))


def str3to10(x):
    num_753 = ['7', '5', '3']
    return "".join([num_753[int(i)] for i in x])


N = input()
c = 0
for i in range(3 ** 10):
    num_753 = str3to10(str10to3(i))
    for i in range(9):
        if int('7' * i + num_753) <= N and set('7' * i + num_753) == set(['7', '5', '3']):
            c += 1
print c



Measured memory_bytes: 8700
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdlib>
using namespace std;

int main(){
	typedef pair<int,int> pii;
	int n, m, k, x, d, h, i, j;
	for(; cin >> n >> m, n; ){
		vector<pair<int,int> > st[151];
		for( i = 1; i <= n; i++ ){
			for( cin >> k; k--; ){
				cin >> x >> d;
				st[i].push_back( make_pair( x, d ) );
			}
		}

		int dp[158][151][10];
		fill( **dp, *dp[158], 1e9 );
		for( i = st[1].size(); i--; ){
			dp[m][1][i] = 0;
		}
		for( i = st[2].size(); i--; ){
			dp[m-1][2][i] = 0;
		}

		for( h = 2; h <= n; h++ ){
			for( i = m; i >= 0; i-- ){
				for( j = st[h].size(); j--; ){
					for( k = st[h-1].size(); k--; ){
						x = dp[i][h-1][k]
						  + ( st[h][j].second + st[h-1][k].second )
						  * abs( st[h][j].first - st[h-1][k].first );
						dp[i][h][j] = min( dp[i][h][j], x );
					}
					for( k = st[h-2].size(); k--; ){
						x = dp[i+1][h-2][k]
						  + ( st[h][j].second + st[h-2][k].second )
						  * abs( st[h][j].first - st[h-2][k].first );
						dp[i][h][j] = min( dp[i][h][j], x );
					}
				}
			}
		}
		x = 1e9;
		for( i = m; i >= 0; i-- ){
			for( j = st[n].size(); j--; ){
				x = min( x, dp[i][n][j] );
			}
		}
		for( i = m; i > 0; i-- ){
			for( j = st[n-1].size(); j--; ){
				x = min( x, dp[i][n-1][j] );
			}
		}
		
		cout << x << endl;
	}
}

Measured memory_bytes: 1868
/*input
3 3
2 1 3
2 1 3
2 1 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 301;
int a[N][N];
bool blocked[N];
int n,m;
vector< pair<int,int>  > all[N];

bool check(int x){
	RE(i,m){
		all[i].clear();
		blocked[i] = 0;
	}
	RE(i,n){
		all[a[i][1]].pb({i,1});
	}
	while(1){
		int wh = 0;
		RE(i,m){
			if(all[i].size() > x)wh = i;
		}
		if(wh == 0)return 1;
		blocked[wh] = 1;
		for(auto it:all[wh]){
			int ind = it.f;
			int pos = it.s;
			while(pos <= m and blocked[a[ind][pos]])pos++;
			if(pos == m+1)return 0;
			all[a[ind][pos]].pb({ind,pos});
		}
		all[wh].clear();
	}
}

void solve(){
  	cin >> n >> m;
  	RE(i,n){
  		RE(j,m){
  			cin >> a[i][j];
  		}
  	}
  	int lo = 1;
  	int hi = n;
  	while(lo < hi){
  		int mid = (lo+hi)/2;
  		if(check(mid))hi = mid;
  		else lo = mid+1;
  	}
  	cout << lo;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 6272
n=int(input())

ans = [0]*n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            if x**2+y**2+z**2+x*y+y*z+z*x <= n:
                ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
for i in range(n):
    print(ans[i])


Measured memory_bytes: 69116
n = int(input())
h = list(map(int, input().split()))

h1=[x-1 for x in h]

prev=h1[0]
for i in range(1,n):
  if prev <= h1[i]:
    prev = h1[i]
  elif prev <= h[i]:
    prev = h[i]
  else:
    print('No')
    exit(0)
  

print('Yes')


Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int k,a,b;
	cin>>k>>a>>b;
	int f=0,ans;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			ans=i;
		    f=1;
		    i=b+1;
		}
	}
	if(f==1)
	cout<<"OK"<<endl;
	else
	cout<<"NG"<<endl;
	
	
}

Measured memory_bytes: 3628
#include <unistd.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))

char ibuf[1400100];
char *ibufe = ibuf-1;

inline void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[6];
char *bufe = buf;

void write_uintln(int x){
  int i;
  static char tmp[6];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

inline void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


int n, m;
int A[100000];

int main(){
  int i;
  readall();
  n = read_uint();
  m = read_uint();
  for(i=0;i<m;i++){
    int a, b;
    a = read_uint();
    b = read_uint();
    A[a-1] = MAX(A[a-1], n-b+1);
  }
  int min = 0;
  int count = 0;
 
  for(i=0;i<n-1;i++){
    min = MAX(min, A[i]);
    if(i == n-min-1){
      min = 0;
      count++;
    }
  }

  write_uintln(count);
  writeall();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    int c = 0;
    REP(i, n) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) {
            c++;
            if (c >= 3) {
                cout << "Yes" << endl;
                return;
            }
        } else c = 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3652
m = 1000000007


r1, c1, r2, c2 = map(int, input().split())

nf = 10 ** 6 * 2 + 100
fact = [0] * (nf + 1)
fact[0] = 1
for i in range(nf):
    fact[i + 1] = fact[i] * (i + 1) % m


def F(r, c):
    path = (fact[r + c + 2] % m) * pow(fact[r + 1] * fact[c + 1], m - 2, m) % m
    return path - 1


r1 -= 1
c1 -= 1

ans = F(r2, c2)
ans -= F(r1, c2)
ans -= F(r2, c1)
ans += F(r1, c1)
ans = ans % m

print(ans)

Measured memory_bytes: 82164
import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String S = sc.next();
        int price = 700;
        for (int i = 0; i < S.length(); i++){
            if (S.substring(i, i + 1).equals("o")){
                price += 100;
            }
        }
        
        out.println(price);

        //テンプレ
        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 35712
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <numeric>

using namespace std;

int main() {
	long long int n, m, c=0;
	cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<n-2;i++) {
       if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') c++;
     }

    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <limits.h>
#include <string.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vii;

typedef long long int lld;

#define F first
#define S second

#define ERR 1e-9
#define MAXN 100010

#ifndef ONLINE_JUDGE
    #define var(x) cerr << #x << ": " << x;
#else
    #define var(x)
#endif // ONLINE_JUDGE

void aggMax(int & res, int x){ if(x > res)res = x; }
void aggMin(int & res, int x){ if(x < res)res = x; }

int II(){ int i; cin >> i; return i; }
void OI(int i){ cout << i; }

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/

    int N = II(), T = II(), res = 10000;
    while(N --){
        int c = II(), t = II();
        if(t > T)continue;
        aggMin(res, c);
    }
    if(res == 10000)cout << "TLE";
    else cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}

int main(){
	vector<vector<int>> c;
	vector<int> vec = getv<int>(3);
	c.emplace_back(vec);
	vec = getv<int>(3);
	c.emplace_back(vec);
	vec = getv<int>(3);
	c.emplace_back(vec);
	int sum3;
	sum3 = c[0][0]+c[1][1]+c[2][2];


	if(sum3==c[0][1]+c[1][2]+c[2][0]
		&& sum3==c[0][2]+c[1][0]+c[2][1]
		&& sum3==c[0][0]+c[1][2]+c[2][1]
		&& sum3==c[0][1]+c[1][0]+c[2][2]
		&& sum3==c[0][2]+c[1][1]+c[2][0])
		Out(true);
	else Out(false);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int N, K, i;
  double sum, max;
  double p[200001];
  
  scanf("%d %d", &N, &K);
  for (i = 0; i < N; i++)
  {
    scanf("%lf", &p[i]);
    p[i] = (p[i] + 1) / 2;
  }
  
  sum = 0;
  max = 0;
  for (i = 0; i < K - 1; i++)
  {
    sum = sum + p[i];
  }
  for (i = K - 1; i < N; i++)
  {
    sum = sum + p[i];
    if (max < sum)
    {
      max = sum;
    }
    sum = sum - p[i-K+1];
  }
  
  printf("%f\n", max);
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define MAXSIZE 100005

class UnionFind{
public:
    UnionFind(ll n){
        size = n;
        parent = vector<ll>(size,-1);
    }
    ll getSize(){return size;}
    ll getParentElement(ll index){return parent[index];}
    ll getGroupSize(ll index){return abs(getParentElement(find(index)));}
    bool isSame(ll x, ll y){return find(x)==find(y);}
    void printParent(){
        for(auto v: parent) {cout << v << " ";}
        cout << endl;
    }
    ll find(ll x){
        ll a = x;
        vector<ll> children;
        while(parent[a]>=0){
            children.push_back(a);
            a = parent[a];
        }
        for(auto child: children){parent[child] = a;}
        return a;
    }
    ll Union(ll x, ll y){
        ll root_x = find(x);
        ll root_y = find(y);
        if(root_x != root_y){
            if(parent[root_x]>=parent[root_y]){
                parent[root_x] += parent[root_y];
                parent[root_y] = root_x;
            }else{
                parent[root_y] += parent[root_x];
                parent[root_x] = root_y;
            }
        }
        return parent[root_x];
    }
private:
    ll size;
    vector<ll> parent;
};

int main(){
    ll n;
    cin >> n;
    UnionFind uf(MAXSIZE*2);
    ll x, y;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        uf.Union(x, y+MAXSIZE);
    }
    map<ll, ll> mpx, mpy;
    for(int i = 0; i < MAXSIZE; i++){
        mpx[uf.find(i)]++;
        mpy[uf.find(i+MAXSIZE)]++;
    }
    ll ans = 0;
    for(int i = 0; i < 2*MAXSIZE; i++){
        ans += mpx[i]*mpy[i];
    }
    cout << ans - n << endl;
    return 0;

}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN
    string s; ll k;
    cin>>s>>k;

    vector<string> st(0);
    REP(i,5){
        REP(j,s.size()){
            if(j+i<s.size()){
                if (!count(ALL(st), s.substr(j,i+1))){
                    st.push_back(s.substr(j,i+1));
                }

            }
        }
        
    }
    VSORT(st);
    // REP(i,5){
    //     cout<<st[i]<<endl;
    // }
    cout<<st[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 1152
//Chat I am Trash
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define debug(x) cout<<x<<endl
#define all(x) x.begin(),x.end()

using namespace std;
int main()
{
    FASTIO
    vector <ll > ve[5];
    for(ll i=0;i<3;i++)
    {
      ll u,v;
      cin >> u >> v;
      ve[u-1].pb(v-1);
      ve[v-1].pb(u-1);
    }
bool ok = true;
    for(ll i=0;i<=3;i++)
    {
      if(ve[i].size()>2)
      ok=false;
    }
    if(ok)cout<<"YES";
    else
    cout<<"NO";


return 0;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  int n,m;
  cin>>n>>m;
  int mn=INFTY,mx=0;

  rep(i,m){
    int l,r;
    cin>>l>>r;
    mn = min(mn,r);
    mx = max(mx,l);
    //cout<<mx<<mn;
  }
  if(mn-mx+1>=0)cout<<mn-mx+1;
  else cout<<0;
  return 0;
}

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

typedef unsigned long ul;
typedef long long int ll;
typedef pair<ll, ll> P;
#define pb push_back
#define mp make_pair
#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)
#define ALL(a) (a).begin(),(a).end()
#define dump(x) cout << #x << " = " << (x) << endl

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

    int n, k;
    cin >> n >> k;
    if ((n+1)/2 < k) {
        cout << "NO" << '\n';
    } else {
        cout << "YES" << '\n';
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	double a, cnt = 0.0;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%lf",&a);
		cnt += 1/a;
	}
	printf("%.6lf", 1/cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


ll a[200010];
int n;
vector<ll> acc;

ll calc(int idx1, int idx2, ll left, ll right){
    ll b = acc[idx1];
    ll c = left - acc[idx1];
    ll d = acc[idx2] - left;
    ll e = acc[n] - acc[idx2];
    ll mn = min({b, c, d, e});
    ll mx = max({b, c, d, e});
    return mx - mn;
}
 
 
int main(){
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n+1) acc.push_back(0);
    rep(i, n) acc[i+1] += acc[i] + a[i];
    ll ans = LINF;
 
    for(int i = 2; i < n-1; i++){
        ll left = acc[i];
        ll right = acc[n] - acc[i];
        int idx1 = lower_bound(acc.begin(), acc.end(), left/2) - acc.begin();
        int idx2 = lower_bound(acc.begin(), acc.end(), left+right/2) - acc.begin();
        ans = min(ans, calc(idx1, idx2, left, right));
        ans = min(ans, calc(idx1, idx2-1, left, right));
        ans = min(ans, calc(idx1-1, idx2, left, right));
        ans = min(ans, calc(idx1-1, idx2-1, left, right));
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6832
module Enumerable
  def scan_left(init = 0)
    inject([init]) { |a, n| a << yield(a.last, n) }
  end
end

n = gets.to_i
ns = gets.split.map(&:to_i)

ls = ns.scan_left(&:gcd)
rs = ns.reverse.scan_left(&:gcd).reverse
# p ls, rs

as = Array.new(n) do |i|
  l = ls[i]
  r = rs[i + 1]
  l.gcd r
end
p as.max


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

using namespace std;

#define inputInt(a) scanf("%d", &a)
#define inputStr(a) getline(cin, a)
#define clr(a) memset(a, 0, sizeof(a))
#define print(a) cout<<a<<endl

int main()
{
    double r,g,b;
    cin>>r>>g;
    b = 2*g - r;
    cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 256
package main
import(
  "fmt"
)
func main(){
  var n, i, j int
  fmt.Scan(&n)
  for i=0;i<=100;i++{
    for j=0;j<=100;j++{
      if i*4+j*7==n{
        fmt.Println("Yes")
        return
      }
    }
  }
  fmt.Println("No")
}


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

typedef long long ll;
using namespace std;

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


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

ll comb[333][333];
ll dp[333][333];
ll d[333];
ll N,M,K;
void make_caomb(){
	REP(i,333)comb[i][0] = comb[i][i] = 1;
	REP(i,333){
		for(int j = 1;j < i;j++){
			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % M;
		}
	}
}

int main(){
	cin >> N >> K >> M;
	make_caomb();
	REP(i,333)dp[1][i] = 1;
	for(int i = 2;i <= N + 1;i++){
		REP(j,333)d[j] = 0;
		for(int j = K-1;j >= 0;j--){
			for(int k = 0;k < i;k++){
				d[k] = (d[k]+dp[k][j+1])%M;
			}
			for(int k = 1;k < i;k++){
				dp[i][j] = (dp[i][j] + dp[i-k][j]*d[k]%M*comb[i-2][k-1]%M) % M;
			}
		}
	}
	cout << dp[N+1][0] << endl;
	return 0;
}


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

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll E = count(s.begin(),s.end(),'E');
  ll W = count(s.begin(),s.end(),'W');
  ll mn = s.size();
  ll e=0,w=0;
  rep(i,n){
    ll cnt = w + ( E - e );
    if( s[i] == 'E' ){
      e++;
      cnt--;
    }
    if( s[i] == 'W' ) w++;
    if( cnt < mn ){
      mn = cnt;
    }
  }
  cout << mn << endl;
      
  return 0;
}

Measured memory_bytes: 900
var data = '';
var readable = process.stdin;

readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  data += chunk;
} )
readable.resume();
readable.on( 'end', function() {
  var x = parseInt( data );
  console.log( '%d', Math.pow( x, 3 ) );
} )

Measured memory_bytes: 7648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    ll a, b;
    int k;
    cin >> a >> b >> k;
    rep(i, k) {
        if ( !(i&1) ) {
            if ( a&1 ) --a;
            b += a / 2;
            a /= 2;
        }
        else {
            if ( b&1 ) --b;
            a += b / 2;
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		boolean first = true;
		for(;;){

			int N = cin.nextInt();
			if(N==0){
				break;
			}
			if(first){
				first=false;
			}
			else{
				System.out.println();
			}
			Team t[] = new Team[N];
			for(int i=0;i<N;i++){
				String s = cin.next();
				int a= cin.nextInt();
				int b= cin.nextInt();
				int c= cin.nextInt();
				t[i]=new Team(s,i,a,b,c);
			}
			Arrays.sort(t);
			
			for(int i = N-1;i>=0;i--){
				System.out.println(t[i].name+","+t[i].total);
			}
		}
		
	}

}
class Team implements Comparable{
	String name;
	int num;
	int win;
	int lose;
	int drow;
	int total;
	Team(String s,int a,int b,int c,int d){
		name=s;
		num=a;
		win=b;
		lose=c;
		drow=d;
		total = b*3+drow;
	}
	public int compareTo(Object o){
		Team t = (Team)o;
		if(this.total==t.total){
			return t.num-this.num;
		}
		else{
			return this.total-t.total;
		}
	}
	
}

Measured memory_bytes: 12000
n,a,b,c,d = map(int,input().split())
s = "s" + input()

for i in range(a,max(c,d)-1):
        if s[i] == s[i+1] == "#":
            print("No")
            exit()
if c < d:
    print("Yes")
else:
    for i in range(b,d+1):
        if s[i+1] == s[i-1] == s[i] == ".":
            print("Yes")
            exit()
    print("No")


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

int main() {
  int N,l,r;
  int seat = 0;
  cin >> N;
  
  for(int i = 0;i < N;i++){
    cin >> l >> r;
    seat += r - l + 1;
  }
  
  cout << seat << endl;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"
# include "cstring"

using namespace std;

const int maxm=2e5+10;

char S[maxm];

int main(){
	register int i,N,Sum=0;
	register long long Ans=0;
	scanf("%s",S+1);
	N=strlen(S+1);
	for(i=1;i<=N;i++){
		switch(S[i]){
			case 'B':
				Sum++;
				break;
			case 'W':
				Ans+=Sum;
				break;
		}
	}
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;


int main()
{
  fastio
  int n;
  ll k;
  cin >> n >> k;
  int a[n+1];
  for(int i=1; i<=n; i++) cin >> a[i];
  vi cycle;
  /* cycle.PB(1); */
  int i=a[1];
  map<int, int> m;
  /* m[1]=1; */
  /* while(i!=1) cycle.PB(i), i=a[i], cout << i; */
  while(!m.count(i)) cycle.PB(i), m[i]=1, i=a[i] ;
  int start = a[cycle.back()];
  vi edge;
  while(cycle[0]!=start)
  {
    edge.PB(cycle[0]);
    cycle.erase(cycle.begin());
  }
  if(k<=edge.size())
  {
    cout << edge[k-1] ;
    return 0;
  }
  k -= edge.size();
  int len = cycle.size();
  k--;
  k%=len;
  

  /* for(auto &j:cycle) cout << j << " "; */
  cout << cycle[k];

  return 0;
}




Measured memory_bytes: 15356
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    REP(i, N) {
        if ((i + 1) % 2 == 1 && a[i] % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
	int n,m;
	cin>>n>>m;
	vi a(n);
	int sum=0;
	rep(i,0,n){
		cin>>a[i];
		sum+=a[i];
	}
	int l=sum/(4*m);
	if(sum%(4*m)!=0)l++;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(a[i]<l){
			cnt++;
		}
	}
	if(cnt>n-m){
		cout<<"No\n";
	}
	else{
		cout<<"Yes\n";
	}
}

signed main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000002


int main(){
	int A,B,C;
	cin>>A>>B>>C;
	
	int K;
	cin>>K;
	
	while(A>=B){
		B*=2;
		K--;
	}
	
	while(B>=C){
		C*=2;
		K--;
	}
	
	if(K>=0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>

#define ll long long
using namespace std;

int main() {
	ll a, b, k, hoge[200], flag;
    cin >> a >> b >> k;
	flag = 0;
	for (int i = 1; i < 101; i++) {
		if (a%i == 0 && b%i == 0) {
			hoge[flag] = i;
			flag++;
		}
	}
	cout << hoge[flag - k] << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
 
fn main() { 
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let n = it.next().unwrap();
    if n == 0 {
        println!("{}",  1 );
  } else {
        println!("{}", 0 );
  }
}

Measured memory_bytes: 2124
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cnt = 1;
		while(sc.hasNext()) {
			int W = sc.nextInt();
			if(W == 0) break;
			int N = sc.nextInt();
			int[] v = new int[N];
			int[] w = new int[N];
			for(int i = 0; i < N; i++) {
				String[] s = sc.next().split(",");
				v[i] = Integer.parseInt(s[0]);
				w[i] = Integer.parseInt(s[1]);
			}
			int[][] dp = new int[N + 1][W + 1];
			for(int i = 0; i <= N; i++) {
				for(int j = 0; j <= W;  j++) {
					dp[i][j] = -1;
				}
			}
			dp[0][0] = 0;
			for(int i = 0; i < N; i++) {
				for(int j = 0; j <= W; j++) {
					dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
					int t = j + w[i];
					if(dp[i][j] != -1 && t <= W) {
						dp[i + 1][t] = Math.max(dp[i + 1][j], dp[i][j] + v[i]);
					}
				}
			}
			int wei = 0;
			int val = 0;
			for(int i = 0; i <= W; i++) {
				if(val < dp[N][i]) {
					val = dp[N][i];
					wei = i;
				}
			}
			System.out.printf("Case %d:\n", cnt);
			System.out.println(val);
			System.out.println(wei);
			cnt++;
		}
		sc.close();
	}
}


Measured memory_bytes: 37924
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef long long  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 100+7;
const ll INF = 1e8;


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

    ll n,k;
    cin>>n>>k;
    cout<<min(n%k,k-n%k)<<endl;
    return 0;
}


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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

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

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

vector<int> G[300001], rG[300001];
int n,m;

vector<int> topological_sort(){
    int indeg[n];
    set<int> st; // 入次数が0の頂点の番号
    fill(indeg, indeg+n, 0);
    for(int i=0;i<n;++i) for(int to: G[i]) indeg[to]++;
    for(int i=0;i<n;++i) if(indeg[i] == 0) st.insert(i);

    vector<int> ret;
    int used[n];
    fill(used, used+n, 0);
    while(!st.empty()){
        int node = *st.begin();
        st.erase(node);
        ret.push_back(node);
        used[node] = 1;
        for(int next: G[node]){
            --indeg[next];
            if(!used[next] && indeg[next] == 0) st.insert(next);
        }
    }
    return ret;
}

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

    cin >> n >> m;
    int x,y;
    vector<Pii> edges;
    for(int i=0;i<n-1+m;++i) {
        cin >> x >> y;
        G[x].push_back(y);
        rG[y].push_back(x);
    }

    ++n;
    vector<int> nodes = topological_sort();

    int par[n+1];
    int depth[n+1];
    vector<int> ancestors[n+1];
    fill(par, par+(n+1), -1);
    par[nodes[1]] = 0;
    depth[nodes[1]] = 0;
    for(int i=1;i<n;++i) {
        for(int y: G[nodes[i]]) {
            // cerr << "*" <<  y << endl;
            par[y] = nodes[i];
            depth[nodes[i]] = depth[nodes[i]]+1;
        }
        // cerr << nodes[i] << " " << par[nodes[i]] << endl;
    }

    for(int i=1;i<n;++i) cout << par[i] << endl;

}


Measured memory_bytes: 28408
n = int(input())
a = input().split()
b = list(a[0])
c = list(a[1])

list = []
for i in range(n):
    list.append(b[i])
    list.append(c[i])

mojiretu = list[0]
for i in range(1, len(list)):
    mojiretu += list[i]
print(mojiretu)


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

string s;
int res = 0;
int main(){
  cin >> s;
  for(int i=0;i<4;i++){
    if(s[i]=='+')res++;
    //"(ダブルクオート)と'(シングルクオート)はc++で意味が異なる
    //前者は文字列のアドレスを返し、後者は文字リテラル(char)を返す
    else res--;
  } 
  cout << res<<endl;
}



Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] data = Console.ReadLine().Split(' ');
        int a = int.Parse(data[0]);
        int b = int.Parse(data[1]);
        int c = int.Parse(data[2]);
        int count = 0;
        for (int i = a; i <= b; i++)
        {
            if (c % i == 0)
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << C-min(A-B,C) << endl;
}

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

template<typename T>
struct List {
    struct Node {
        Node *prev, *next;
        T data;
        Node(Node* prev = nullptr, Node* next = nullptr, T data = T())
        : prev(prev), next(next), data(data) { }
    };
    Node *head, *tail;
    List() : head(new Node()), tail(new Node()) {
        head->next = tail, tail->prev = head;
    }
    Node* begin() { return head->next; }
    Node* end() { return tail; }
    Node* insert(Node* cur, T data) {
        cur = new Node(cur->prev, cur, data);
        return cur->prev->next = cur->next->prev = cur;
    }
    Node* push_front(T data) { return insert(begin(), data); }
    Node* push_back(T data) { return insert(end(), data); }
    Node* erase(Node* cur) {
        if (cur == head || cur == tail) return cur;
        cur->prev->next = cur->next, cur->next->prev = cur->prev;
        Node* tmp = cur->next;
        return free(cur), tmp;
    }
    Node* pop_front() { return erase(begin()); }
    Node* pop_back() { return erase(end()->prev); }
    Node* find(T data) {
        Node* cur = begin();
        while (cur != end() && cur->data != data) cur = cur->next;
        return cur;
    }
    friend ostream& operator<<(ostream& os, List& li) {
        Node* cur = li.begin();
        for (int cnt = 0; cur != li.end(); cur = cur->next) {
            if (cnt++) os << " "; os << cur->data;
        }
        return os;
    }
    Node* swap_by_pivot(Node* cur) {
        if (cur->prev == head && cur->next != tail) {
            cur->next->prev = head;
            tail->prev->next = cur;
            head->next = cur->next;
            cur->prev = tail->prev;
            cur->next = tail;
            tail->prev = cur;
            return cur;
        }
        if (cur->prev != head && cur->next == tail) {
            cur->prev->next = tail;
            head->next->prev = cur;
            tail->prev = cur->prev;
            cur->next = head->next;
            cur->prev = head;
            head->next = cur;
            return cur;
        }
        if (cur->prev != head && cur->next != tail) {
            cur->prev->next = tail;
            cur->next->prev = head;
            tail->prev->next = cur;
            head->next->prev = cur;
            swap(tail->prev, cur->prev);
            swap(head->next, cur->next);
            return cur;
        }
        return cur;
    }
};

int main() {
    List<int> li;
    int n, q; cin >> n >> q;
    vector<List<int>::Node*> pos(n + 1);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        pos[a] = li.push_back(a);
    }
    while (q--) {
        int x; cin >> x;
        li.swap_by_pivot(pos[x]);
    }
    cout << li << endl;
	return 0;
}



Measured memory_bytes: 6760
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
    bool prime[1000000];
    for(int i = 0; i < 1000000; i++){
        prime[i] = true;
    }
    prime[0] = prime[1] = false;

    for(int i = 1; i < sqrt(1000000); i++){
        if(prime[i]){
            for(int j = 0; i * (j + 2) <= 1000000; j++){
                prime[i * (j + 2)] = false;
            }
        }
    }
    vector<int> p;
    p.push_back(-1);
    for(int i = 2; i < 1000000; i++){
        if(prime[i]){
            p.push_back(i);
        }
    }

    while(1){
        int a, d, n;
        scanf("%d %d %d", &a, &d, &n);
        if(a == 0 && d == 0 && n == 0)
            break;

        int count = 0;
        for(int i = a; i < 1000000; i += d){
            if(prime[i]){
                count++;
                if(n == count){
                    printf("%d\n", i);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	FastReader sc = new FastReader();
	int n = sc.nextInt();
	Set<Integer> set = new HashSet<>();
	
	for (int i = 0; i < n; i++) {
		int num = sc.nextInt();
		
		if (set.contains(num)) {
			set.remove(num);
		} else {
			set.add(num);
		}
	}
	System.out.println(set.size());
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


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

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

int main(){
    int x,y;
    cin >> x >> y;
 
    if(x<y){
        int t = x;
        x = y;
        y=t;
    }
        
    cout << gcd(x,y) << endl;
 
    return 0;
    }

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

int main() {
	int N, A, B, C, X;
	while (cin >> N >> A >> B >> C >> X) {
		if (N == 0) return 0;
		vector<int> Y(N);
		for (int i = 0; i < N; i++) cin >> Y[i];
		int ANS = -1, NOW = 0;
		for (int i = 0; i <= 10000; i++) {
			if (X == Y[NOW]) NOW++;
			if (NOW == N) {
				ANS = i;
				break;
			}
			X = (X * A + B) % C;
		}
		cout << ANS << endl;
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

void solve();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;//testcases
    cin>>t;
    int p = t%10;
    if(p==2 || p==4 || p==5 || p==7|| p==9) cout << "hon";
    else if(p==0 || p==1 || p==6|| p==8) cout << "pon";
    else if(p==3) cout << "bon";
	return 0;
}



Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<map>
#include<tuple>
using namespace std;
#define INF 1100000000000
#define MAX 1100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
//__builtin_popcount(S)

ll dp[110][110000],sum[110000];

int main(){
    int N,K,a[110];
    cin>>N>>K;
    for(int i=1;i<=N;i++) cin>>a[i];
    dp[0][0]=1;

    for(int i=1;i<=N;i++){
        sum[0]=0;
        for(int j=1;j<=K+1;j++){
            sum[j]=(sum[j-1]+dp[i-1][j-1])%MOD;
            //cout<<i<<" "<<j<<" "<<sum[j]<<endl;
        } 
        for(int j=0;j<=K;j++){
            dp[i][j]=(sum[j+1]-sum[max(0,j-a[i])]+MOD)%MOD;
            //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        } 
    
    }

    cout<<dp[N][K]<<endl;
}



Measured memory_bytes: 87424
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

#[allow(dead_code)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        return x;
    }
    gcd(y, x % y)
}

#[test]
fn test_primes() {
    assert_eq!(primes(1), vec![1]);
    assert_eq!(primes(140), vec![1, 2, 2, 5, 7])
}

#[allow(dead_code)]
fn primes(num: i64) -> Vec<i64> {
    let mut ans = vec![1];
    let mut cur = num;
    for i in 2.. {
        if i * i > num { break; }
        if cur % i == 0 {
            while cur % i == 0 {
                ans.push(i);
                cur /= i;
            }
        }
    }
    if cur > 1 {
        ans.push(cur);
    }
    return ans;
}


test! {
r"2 5
" => r"10",

r"5 10
" => r"-1",

r"9 9
" => r"81"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        a:i64,
        b:i64,
//        a:[i32;n],
    }
    let a: i64 = a;
    let b: i64 = b;

    let ans = if a > 9 || b > 9 {
        -1
    } else {
        a * b
    };

    format!("{}", ans)
}


fn main() {
    println!("{}", solve(&stdin!()));
}



Measured memory_bytes: 4352