akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AMeasure {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            String s = in.string();
            out.println(s.length() == 2 ? s : new StringBuilder(s).reverse());
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 22740
#include<iostream>
#include<cmath>
//using namespace std;
int n,i,e,w,s=1e9,a[1<<19];
char c[1<<19];
int main()
{
	for(std::cin>>n;i<n;std::cin>>c[i],a[i]=w,w+=c[i++]==87);
	for(;i>0;s=fmin(s,a[--i]+e),e+=c[i]==69);
	std::cout<<s<<std::endl;
}

Measured memory_bytes: 1664
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int n;
int vi[100010];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin>>n;
  int paircnt=0, ans=0;
  REP(i,n)
  {
    int p; cin>>p;
    vi[p]++;
  }
  REP(i,100010)
  {
    int q=vi[i];
    if (q==0) continue;
    if (q%2==0) paircnt++;
    ans++;
  }
  if (paircnt%2==0) ans=ans;
  else              ans--;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	int x, y;
	for (int i = 0;; i++) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x >= y) {
			cout << y << " " << x <<"\n";

		}
		else {
			cout << x << " " << y <<"\n";
		}
	}
}


Measured memory_bytes: 3108
import java.util.*;
public class Main{
public static void main(String[] args){
   Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
  int num = Integer.parseInt(str);
  if(num >= 2000){ 
  }else if(num >= 1800){
    System.out.println("1");
  }else if(num >= 1600){
    System.out.println("2");
  }else if(num >= 1400){
    System.out.println("3");
  }else if(num >= 1200){
    System.out.println("4");
  }else if(num >= 1000){
    System.out.println("5");
  }else if(num >= 800){
    System.out.println("6");
  }else if(num >= 600){
    System.out.println("7");
  }else if(num >= 400){
    System.out.println("8");
  }
}
}

Measured memory_bytes: 35688
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n;
	string s; cin >> n >> s;
	
	cout << (s.substr(0, s.size() / 2) == s.substr(s.size() / 2) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int  long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 998244353
// order_of_key and *find_by_order
#define N 100001
int val[10001];
int32_t main() {
	fast;
	int n;
	cin >> n;

	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			for (int k = 1; k <= 100; k++) {
				if (i * i + j * j + k * k + i * j + j * k + k * i <= 10000)
					val[i * i + j * j + k * k + i * j + j * k + k * i]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << val[i] << "\n";
	}
}











Measured memory_bytes: 3680
from collections import Counter
n = int(input())
D = list(map(int, input().split()))
p = 998244353

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

count_dict = sorted(Counter(D).items(), key=lambda x:x[0])
count_list = list(dict(count_dict).values())

if len(count_list) == max(D) + 1 and not 0 in D[1:]:
    ans = 1
    for i in range(len(count_list)):
        if i == 0:
            if D[0] == 0:
                pass
            else:
                ans = 0
                break
        else:
            ans *= power_func(count_list[i - 1], count_list[i], p)
else:
    ans = 0

ans %= p
print(ans)

Measured memory_bytes: 26968
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#define	f first
#define s second
using namespace std;
int main(){

  vector <pair<double,double> > p;
  int n,i,j;

  p.push_back(make_pair(0,0));
  p.push_back(make_pair(100,0));
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;p[j].f!=100;j+=4){
      p.insert(p.begin()+j+1,make_pair((p[j+1].f+p[j].f*2)/3,(p[j+1].s+p[j].s*2)/3));
      p.insert(p.begin()+j+2,make_pair((p[j+2].f*2+p[j].f)/3,(p[j+2].s*2+p[j].s)/3));
      p.insert(p.begin()+j+2,make_pair((p[j+2].f-p[j+1].f)*cos(M_PI/3)-(p[j+2].s-p[j+1].s)*sin(M_PI/3\
)+p[j+1].f,(p[j+2].f-p[j+1].f)*sin(M_PI/3)+(p[j+2].s-p[j+1].s)*cos(M_PI/3)+p[j+1].s));
    }
  }
  for(i=0;i<p.size();i++) cout<<p[i].f<<" "<<p[i].s<<endl;
  return 0;
}

Measured memory_bytes: 3320
#include<bits/stdc++.h>
#define lowbit(i) (i&(-i))
#define ll long long
#define mid ((l+r)>>1)
using namespace std;
const int N=1005,M=2e5+5;
int n,m; vector<int> Ed[N];
struct st
{
	int from,nxt,to,ans;
}ed[M]; int head[N],num;
void add(int from,int to)
{
	ed[++num].to=to,ed[num].from=from;
	ed[num].nxt=head[from];
	head[from]=num;
}
int stk[N],top,dfn[N],low[N],refl[N],t,numb; bool cn[N];
void tarjan(int x)
{
	dfn[x]=low[x]=++numb,stk[++top]=x,cn[x]=1;
	for(int u,i=head[x];i;i=ed[i].nxt)
	{
		u=ed[i].to;
		if(!dfn[u])tarjan(u),low[x]=min(low[x],low[u]);
		else if(cn[u])low[x]=min(low[x],dfn[u]);
	}
	if(dfn[x]==low[x])
	{
		++t;
		while(stk[top]!=x)
			refl[stk[top]]=t,cn[stk[top]]=0,--top;
		refl[stk[top]]=t,cn[stk[top]]=0,--top;
	}
}
int fir[2][N];
void dfs(int x,int id,int typ)
{
	fir[typ][x]=id;
	for(auto u : Ed[x])
		if(!fir[typ][u])dfs(u,id,typ);
}
int E[M],tot;
int main()
{
	//freopen("bigcycle_0.in","r",stdin);
	//freopen("0709D.out","w",stdout);
	int u,v; scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&u,&v),add(u,v),Ed[u].push_back(v);
	for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i);
	for(int i=1;i<=m;i++)if(refl[ed[i].to]==refl[ed[i].from])ed[i].ans=1;
	for(int x=1;x<=n;x++)
	{
		for(int i=1;i<=n;i++)fir[0][i]=fir[1][i]=0;
		fir[0][x]=fir[1][x]=1,tot=0;
		for(int i=head[x];i;i=ed[i].nxt)E[++tot]=i;
		for(int i=1;i<=tot;i++)if(!fir[0][ed[E[i]].to])dfs(ed[E[i]].to,E[i],0);
		for(int i=tot;i;i--)if(!fir[1][ed[E[i]].to])dfs(ed[E[i]].to,E[i],1);
		for(int i=head[x];i;i=ed[i].nxt)
			if(fir[0][ed[i].to]!=i||fir[1][ed[i].to]!=i)ed[i].ans++;
	}
	for(int i=1;i<=m;i++)
		if(ed[i].ans==1)printf("diff\n");
		else printf("same\n");
	//cerr<<clock();
	return 0;
}
/*
3 3
1 2
2 3
1 3
*/

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

int main() {
  /*cin.tie(0);
  ios::sync_with_stdio(false);*/
  int n;
  scanf("%d", &n);
  int a[n][2];
  rep(i, n) {
    rep(j, 2) {
      scanf("%d", &a[i][j]);
    }
  }

  int max = 0;
  int ans;
  rep(i, n) {
    if(a[i][0] > max) {
      max = a[i][0];
      ans = a[i][0] + a[i][1];
    }
  }


  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

#include <string.h>

int main()

{

    char ara[100] ;

    gets(ara) ; int flag = 0 ;

    int len = strlen( ara ) , count = 0 ;

    for( int a = 0 ; ara[a] != '\0' ; a++ )  {

        if( ara[0] == 'A' )  {

            for( int b = 2 ; b <= ( len - 2 ) ; b++ )  {

                if( ara[b] == 'C' )  {

                    count++ ;

                }
 //printf("%d\n",count) ;
            }

            if( count == 1 )  {

                for( int c = 0 ; ara[c] != '\0' ; c++ )  {

                    if(   ara[c] >= 'D' && ara[c] <= 'Z'  )  {

                       printf("WA\n") ;

                       return 0 ;

                    }

                    if( ara[c] == 'B' )  {

                        printf("WA\n") ;

                        return 0 ;

                    }



                }
                
                 printf("AC\n") ;
                 
                   return 0 ;
            }

            else  {

                printf("WA\n") ;

                        return 0 ;

            }

        }

        else  {

            printf("WA\n") ;

            return 0 ;

        }

    }



    

}


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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A){
  if (A.size() == n+1){
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]){
        now += d[i];
      }
    }
    ans = max(ans, now);
    return;
  }
  
  A.push_back(A.back());
  while (A.back() <= m){
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int h,a;

    cin>>h;
    cin>>a;
    vector<int> ss(a);
    for(int i=0;i<a;i++)
    {
        cin>>ss[i];
    }
    int summ=accumulate(ss.begin(),ss.end(),0);
    //cout<<summ;
    if(summ>=h)
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
    

    return 0;
    
}

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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define pp pop_back
#define pf push_front
#define sqr(a) (a)*(a)
#define mpr(a,b) make_pair(a, b)
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mpii;
typedef map<string, int> mpsi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef queue<int> qi;
typedef queue<ll> qll;
typedef queue<pair<int, int>> qpi;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pqll;
typedef priority_queue<pair<int,int>> pqpi;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
template<class T> T lcm(T a, T b){return a*(b/gcd(a,b));}
template<class T, class TT>bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans =0;
	for(int i = 0; i < n; i ++)
	{
		string d1, d2;
		d1 = s.substr(0,i+1);
		d2 = s.substr(i+1,n-i-1);
		map<int,int> mp, mp2;
		for(auto it : d1)
			mp[it] =1;
		int cnt = 0;
		for(auto it : d2)
		{
			if(!mp2[it])
			{
				cnt += (mp[it]);
				mp2[it] = 1;
			}
		}
		umax(ans, cnt);
	}
	cout << ans;
	
	getchar();
	getchar();
	return 0;
	//freopen("Ganiyev.txt", "r", stdin);
	//freopen("Asadullo.txt", "w", stdout);
	//ios::sync_with_stdio(0);
	//cin.tie(0);cout.tie(0);
	
	
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 256
N, A, B = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)

ans = 0

(0..N-2).each{|i|
	if (X[i+1] - X[i]) * A > B
		ans += B
	else
		ans += (X[i+1] - X[i]) * A
	end
}

p ans

Measured memory_bytes: 8460
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int main(){
    int d;
    while(cin >> d){
        int s = 0;
        for(int i=d; i<600; i+=d){
            s += i*i*d;
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int D, N;
    cin >> D >> N;
    V T(D + 1);
    rep(i, D) cin >> T[i + 1];
    V A(N), B(N), C(N);
    rep(i, N) cin >> A[i] >> B[i] >> C[i];

    VV dp(D + 1, V(101, -inf));
    dp[0][0] = 0;
    rep(i, D) {
        rep(c, 101) {
            rep(j, N) {
                if (A[j] <= T[i + 1] && T[i + 1] <= B[j]) {
                    dp[i + 1][C[j]] = max(dp[i + 1][C[j]], dp[i][c] + (i != 0) * abs(C[j] - c));
                }
            }
        }
    }

    cout << *max_element(all(dp[D])) << endl;
}

Measured memory_bytes: 3244
#include <iostream>

using namespace std;

int main()
{
	string c;
	int m;

	while (cin >> c, c != "-") {
		for (cin >> m; m > 0; m--) {
			int h;
			cin >> h;
			c = c.substr(h) + c.substr(0, h);
		}
		
		cout << c << endl;
	}
}

Measured memory_bytes: 3148
// by ul {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}
LL a, b;
void input() {
    scanf("%lld %lld", &a, &b);
}

LL gcd(LL a, LL b) {
    while(b > 0) {
        LL t = b;
        b = a % b;
        a = t;
    }
    return a;
}

void solve() {
    LL g = gcd(a, b);
    LL cnt = 1;
    for(LL i = 2; i*i <= g; i++) {
        if(g % i == 0) {
            cnt++;
            while(g % i == 0) {
                g /= i;
            }
        }
    }
    if(g > 1) cnt++;
    printf("%lld\n", cnt);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
//typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    cin>>n;
    int x=0;
    for(int i=1;i*i<=n;i++){
        //cout << i << " "<< (((n-1)/i))*2 << endl;
        x+=(((n-1)/i))*2;
        x-=(i-1)*2;
    }
    x-=(sqrt(n)-1);
    cout << x << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3708
/*
  In the name of ALLAH
  Author : Raashid Anwar
*/

#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;
mt19937 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());

int cnt[1000001];
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, g = 0;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
    g = __gcd(g, x);
  }
  bool ok = true;
  for(int i = 2; i <= 1000000; i++) {
    int x = 0;
    for(int j = i; j <= 1000000; j += i)
      x += cnt[j];
    if(x > 1) {
      ok = false;
      break;
    }
  }
  if(ok)
    cout << "pairwise coprime\n";
  else if(!ok && g == 1)
    cout << "setwise coprime\n";
  else
    cout << "not coprime\n";
}

Measured memory_bytes: 11448
<?php

$sc = new Scanner();

$H = $sc->nextInt();
$W = $sc->nextInt();

$map = [];

$delte_line = str_repeat('.', $W);

for($i = 0; $i < $H; $i++) {
    $line = $sc->next();
    if($line !== $delte_line) {
        $map[] = str_split($line);
    }
}
$delete_col = str_repeat('.', count($map));
$col_list = [];
for($i = 0; $i < $W; $i++) {
    $col[$i] = array_column($map, $i);
    if (implode($col[$i]) === $delete_col) {
        $col_list[] = $i;
    }
}
$print = '';
foreach($map as $k => $v) {
    foreach($col_list as $i) {
        unset($map[$k][$i]);
    }
    $print .= implode($map[$k]) . PHP_EOL;
}

echo $print . PHP_EOL;

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


Measured memory_bytes: 6648
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define MAXN 100005
int Set[MAXN];
int Root(int x)
{return Set[x]==x?x:Set[x]=Root(Set[x]);}
int N,Q;
int fa[MAXN];
int Que[MAXN][2];
int marked[MAXN];
int main()
{
	char op[3];
	int id;
	long long ans;
	while(~scanf("%d%d",&N,&Q)&&N&&Q)
	{
		memset(Que,0,sizeof Que);
		memset(fa,0,sizeof fa);
		memset(Set,0,sizeof Set);
		memset(marked,0,sizeof marked);
		ans=0;
		Set[1]=1;fa[1]=1;
		for(int i=2;i<=N;i++)
		{
			scanf("%d",fa+i);
			Set[i]=fa[i];
		}
		for(int i=1;i<=Q;i++)
		{
			scanf("%s%d",op,&id);
			if(op[0]=='Q')Que[i][0]=1;
			else {Que[i][0]=2;Set[id]=id;marked[id]++;}
			Que[i][1]=id;
		}
		for(int i=Q;i>=1;i--)
		{
			if(Que[i][0]==1)
				ans+=1LL*Root(Que[i][1]);
			else
			{
				marked[Que[i][1]]--;
				if(!marked[Que[i][1]])
					Set[Que[i][1]]=fa[Que[i][1]];
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4800
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please



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


	int N;
	scanf("%d ", &N);
	int sL[101] = {}, sR[101] = {};
	vector<pair<int, int>> RR, LL;
	int tot = 0;
	rep(i, N) {
		char c;
		int l = 0, r = 0;
		while((c = getchar_unlocked()) >= '(') {
			if (c == '(') r++;
			else {
				if (r > 0) r--;
				else l++;
			}
		}
		tot += r - l;
		if (l < r) {
			if (l <= 100) sR[l] += r;
			else RR.pb({ l,r });
		}
		else {
			if (r <= 100) sL[r] += l;
			else LL.pb({ r,l });
		}
	}

	if (tot != 0) {
		printf("No");
		return 0;
	}

	sort(RR.begin(), RR.end());
	sort(LL.begin(), LL.end());

	int OK = 1;
	int k = 0;
	rep(i, 101) {
		if (sR[i]) {
			if (k < i) OK = 0;
			k += sR[i];
		}
	}
	rep(i, RR.size()) {
		if (k < RR[i].first) OK = 0;
		k += RR[i].second - RR[i].first;
	}
	k = 0;
	rep(i, 101) {
		if (sL[i]) {
			if (k < i) OK = 0;
			k += sL[i];
		}
	}
	rep(i, LL.size()) {
		if (k < LL[i].first) {
			OK = 0;
		}
		k += LL[i].second - LL[i].first;
	}

	if (OK) printf("Yes");
	else printf("No");

	Would you please return 0;
}

Measured memory_bytes: 3220
from itertools import combinations_with_replacement
from functools import reduce
import math

def gcd(numbers):
    return reduce(math.gcd, numbers)

K = int(input())
GCD = [ k for k in range(1, K+1)]
output = []

for v in combinations_with_replacement(GCD, 3):
    if len(set(v))==2:
        bi = 3
    elif len(set(v))==3:
        bi = 6
    else:
        bi = 1
    output.append(gcd(list(v))*bi)
print(sum(output))

Measured memory_bytes: 164868
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

void solve()
{
	int h, w;
	cin>>h>>w;
	string g[30];
	int m[500][500] = {0};
			int r = w;
	for(int i = 0; i < h; i++) cin>>g[i];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(g[i][j] == '#') continue;
			if(j>0 && g[i][j-1]!='#'){
				m[i*r+j][i*r+j-1] = 1;
				// adj[i*r+j].push_back(i*r+j-1);
			}
			if(i+1<h && g[i+1][j]!='#'){
				m[i*r+j][i*r+j+r] = 1;
				// adj[i*r+j].push_back(i*r+r+j);
			}
			if(j+1<w && g[i][j+1]!='#'){
				m[i*r+j][i*r+j+1] = 1;
				// adj[i*r+j].push_back(i*r+j+1);
			}
			if(i>0 && g[i-1][j]!='#'){
				m[i*r+j][i*r+j-r] = 1;
				// adj[i*r+j].push_back(i*r-r+j);
			}
		}
	}
	ll dp[500][500] = {0};
	fill(dp,inf);
	for(int i = 0; i < h*w; i++){
		for(int j = 0; j < h*w; j++){
			dp[i][j] = m[i][j];			
		}
	}
	for(int i = 0; i < h*w; i++){
		for(int j = 0; j < h*w; j++){
			if(!dp[i][j])
			dp[i][j] = inf;			
		}
	}
	for(int i = 0; i < h*w; i++) dp[i][i] = 0;
	for(int k = 0; k < h*w; k++){
		for(int i = 0; i < h*w; i++){
			for(int j = 0; j < h*w; j++){
				dp[i][j] = min({dp[i][k]+dp[k][j], dp[i][j]});
			}
		}
	}	
	for(int k = 0; k < h*w; k++){
		for(int i = 0; i < h*w; i++){
			for(int j = 0; j < h*w; j++){
				dp[i][j] = min({dp[i][k]+dp[k][j], dp[i][j]});
			}
		}
	}	
	for(int k = 0; k < h*w; k++){
		for(int i = 0; i < h*w; i++){
			for(int j = 0; j < h*w; j++){
				dp[i][j] = min({dp[i][k]+dp[k][j], dp[i][j]});
			}
		}
	}	
	// tr(dp);
	// rep(i, h*w){
	// 	rep(j, h*w){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	int ans = 0;
	for(int i = 0; i < h*w; i++){
		for(int j = 0; j < h*w; j++){
			if(dp[i][j]<inf)
			ans = max({ans, (int)dp[i][j]});
		}
	}
		cout<<ans<<endl;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N;
    cin >> N;
    vector<int> p(N);
    vector<bool> b(N);
    rep(i,0,N){
        cin >> p[i];
        --p[i];
        if(p[i]==i) b[i]=true;
    }

    int ans=0;
    rep(i,0,N){
        if(!b[i]) continue;
        ++ans;
        b[i]=false;
        if(i+1<N and b[i+1]) b[i+1]=false;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

map<string,int> t;

int main()
{
	int n;
	cin >> n;
	string last="G";
	for(int i=1;i<=n;++i)
	{
		string s;
		cin >> s;
		if(s[0]!=last[last.length()-1] && i!=1)
		{
			puts("No");
			return 0;
		}
		if(t[s])
		{
			puts("No");
			return 0;
		}
		++t[s];
		last=s;
	}
	puts("Yes");
}

Measured memory_bytes: 256
#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
mod = 998244353
#N = int(input())
N, K = map(int, input().split())
LR = []
for k in range(K):
	L, R = map(int, input().split())
	LR.append((L,R))
counter = [0 for _ in range(N)]
for i in LR:
	l = i[0]
	r = i[1]
	if l < N:
		counter[l] += 1
	if r + 1 < N:
		counter[r+1] -= 1
sm = 0
counter[0] = 1
for k in range(1, N):
	counter[k] += sm
	sm = counter[k]%mod
	if sm == 0:
		continue
	for i in LR:
		l = i[0]
		r = i[1]
		if k + l < N:
			counter[k+l] += sm
			counter[k+l] %= mod
		if k + r + 1 < N:
			counter[k+r+1] -= sm
			counter[k+r+1] %= mod
print(counter[-1]%mod)
#A = list(map(int, input().split()))
#flag = True
#for k in range(N):
#ans = 0
#print(ans)
#print('Yes')
#print('No')

Measured memory_bytes: 86816
#include <stdio.h>

struct point{
	int s;
	int c;
};

int main(){
	int i, j, n, m,checker=0;
	scanf("%d%d",&n,&m);
	struct point d[m],p;
	for(i=0;i<m;i++){
		scanf("%d%d",&d[i].s,&d[i].c);
		if((n!=1)&&(d[i].s==1)&&(d[i].c==0)) checker = 1;
	}
	for(i=0;i<m-1;i++){
		for(j=i+1;j<m;j++){
			if(d[i].s>d[j].s){
				p=d[i];
				d[i]=d[j];
				d[j]=p;
			}
		}
	}
	
	int ans[n];
	for(i=0;i<n;i++) ans[i]=0;
	if(n!=1)ans[0]=1;

	for(i=0;i<m-1;i++){
		for(j=i+1;j<m;j++){
			if((d[i].s==d[j].s)&&(d[i].c!=d[j].c)) {
				checker = 1;
				break;
			}
		}
	}
	if(checker==1) printf("-1");
	else {
		for(i=0;i<m;i++) ans[d[i].s - 1] = d[i].c;
		for(i=0;i<n;i++) printf("%d",ans[i]);
	}
    printf("\n");
}
	


Measured memory_bytes: 128
INF = 10 ** 9
N, K = map(int, input().split())
h = [int(x) for x in input().split()]

dp = [INF] * N
dp[0] = 0

for i in range(N - 1):
    for j in range(1, K + 1):
        if i + j < N:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))

print(dp[N - 1])


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

int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if (b-a<=k&&c-b<=k&&d-c<=k&&e-d<=k&&c-a<=k&&d-a<=k&&e-a<=k&&d-b<=k&&e-b<=k&&e-c<=k) {
    cout<<"Yay!"<<endl;
  }
  else {
    cout<<":("<<endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std; 
 
#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/
 
void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}
 
int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;
 
	if(N==2)   return 1;
	if(N%2==0) return 0;
 
	for(i=3;i<N && N%i!=0;i+=2);
 
	if(i>=N) return 1;
	
	return 0;
}
 
int factorial(int N){  //Nの階乗を求める関数
	int ans=1;
 
	while(N--) ans*=(N+1);
	return ans;
}
 
//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;
 
    x = a[(first + last) / 2];
    i = first; j=last;
 
    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}
 
int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}
 
unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];
 
    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}

int main(){
    int num[100]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int K;

    cin>>K;
    cout<<num[K-1]<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N;
  cin>>N;
  VL U(N-1),V(N-1);
  rep(i,N-1) cin>>U[i]>>V[i];
  ll ans=0;
  rep(i,N) ans+=(i+1)*(N-i);
  rep(i,N-1){
    if(U[i]>V[i]) swap(U[i],V[i]);
    ans-=U[i]*(N+1-V[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6428
n, m = gets.split.map(&:to_i)
cities = m.times.map{ gets.split.map(&:to_i) }.map.with_index{ |a, i| a.unshift(i) }
cities.sort!{ |a, b| (a[1] <=> b[1]).nonzero? || (a[2] <=> b[2]) }

ans = []
k = 1
pref = 1
cities.each do |i, p, y|
  if pref != p
    pref = p
    k = 1
  end
  ans << [i, p.to_s.rjust(6, '0') + k.to_s.rjust(6, '0')]
  k += 1
end
ans.sort_by{ |i, _| i }.each{ |_, s| puts s }

Measured memory_bytes: 44652
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n;
double dp[330][330][330];
int c1,c2,c3;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int x;scanf("%d",&x);
		if(x==1)c1++;
		else if(x==2)c2++;
		else c3++;
	}
//	memset(dp,0x7f,sizeof(dp));
//	dp[c1][c2][c3]=0.0;
	for(int l3=0;l3<=c3;l3++)for(int l2=0;l2<=c2+c3;l2++)for(int l1=0;l1<=c1+c2+c3;l1++)
	{
		if(l1+l2+l3>n)continue;
		if((!l1)&&(!l2)&&(!l3))continue;
		int l4=n-l1-l2-l3;
		double t=1.0*n/(1.0*(l1+l2+l3));
		dp[l1][l2][l3]=t;
	//	cout<<l1<<' '<<l2<<" "<<l3<<" "<<t<<" "<<dp[l1][l2][l3]<<endl;
		if(l1)
		{
			dp[l1][l2][l3]+=dp[l1-1][l2][l3]*(1.0*l1/(1.0*(l1+l2+l3)));
		}
		if(l2)
		{
			dp[l1][l2][l3]+=dp[l1+1][l2-1][l3]*(1.0*l2/(1.0*(l1+l2+l3)));
		}
		if(l3)
		{
			dp[l1][l2][l3]+=dp[l1][l2+1][l3-1]*(1.0*l3/(1.0*(l1+l2+l3)));
		}
		
	}
	printf("%.10lf\n",dp[c1][c2][c3]);
	return 0;
}

Measured memory_bytes: 256128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,m;
  cin>>n>>m;
  Int a[m],b[m];
  for(Int i=0;i<m;i++) cin>>a[i]>>b[i];
  vector<vector<Int> > G(n);
  for(Int i=0;i<m;i++){
    a[i]--;b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  vector<vector<Int> >  used(2,vector<Int>(n,0));
  function<void(Int,Int)> dfs=[&](Int f,Int v){
    if(used[f][v]) return;
    used[f][v]=1;
    for(Int u:G[v]){
      dfs(!f,u);
    }
  };
  dfs(0,0);
  Int e=0,o=0;
  for(Int i=0;i<n;i++){
    if(used[0][i]) e++;
    if(used[1][i]) o++;
    if(used[0][i]&&used[1][i]){
      cout<<n*(n-1)/2-m<<endl;
      return 0;
    }
  }
  cout<<e*o-m<<endl;
  return 0;
}


Measured memory_bytes: 11840
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop();
int top;
int s[100];

int main(){
  int a,b;
  char t[8];

  while( scanf("%s", t) != EOF ){
    if ( t[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);
    } 
    else if ( t[0] == '-' ){
      a=pop();
      b=pop();
      push(b-a);
    } 
    else if ( t[0] == '*' ){
      a=pop();
      b=pop();
      push(b*a);
    } 
    else {
      push(atoi(t));
    }
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  top++;
  s[top]=x;
}
 
int pop(){
  if(top < 0)return 0;
  else top--;
  return s[top+1];
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
using namespace std;
const int N=4e3+10;
int n;
int p[2][N];//B/W
int f[N][N];
int c[2][N][N];//B,W
int a[N];
char b[N];
int main(){
	cin>>n;n*=2;
	FOR(i,1,n){
		cin>>b[i]>>a[i];
		if(b[i]=='B')
			p[0][a[i]]=i;
		else p[1][a[i]]=i;
	}
	FOR(i,1,n/2){
		int s=0;
		//B
		for(int j=p[0][i]+1;j<=n;j++){
			if(b[j]=='B'&&a[j]<i)
				s++;
		}
		for(int j=0;j<=n/2;j++){
			if(p[1][j]>p[0][i])s++;
			c[0][i-1][j]=s;
		}
		s=0;
		for(int j=p[1][i]+1;j<=n;j++){
			if(b[j]=='W'&&a[j]<i)s++;
		}
		for(int j=0;j<=n/2;j++){
			if(p[0][j]>p[1][i])s++;
			c[1][j][i-1]=s;
		}
		
	}
	FOR(i,1,n/2){
		f[i][0]=f[i-1][0]+c[0][i-1][0];
		f[0][i]=f[0][i-1]+c[1][0][i-1];
	}
	FOR(i,1,n/2)
		FOR(j,1,n/2)
			f[i][j]=min(f[i-1][j]+c[0][i-1][j],f[i][j-1]+c[1][i][j-1]);
	cout<<f[n/2][n/2]<<endl;
		
	
		
}

Measured memory_bytes: 98048
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int N, K;
    cin >> N >> K;
    if ((N + 1) / 2 >= K)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


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

score_taro = 0
score_hanako = 0

for i in range(n):
    taro, hanako = input().split()
    if taro > hanako:
        score_taro += 3
    elif taro < hanako:
        score_hanako += 3
    else:
        score_taro += 1
        score_hanako += 1

print('{} {}'.format(score_taro, score_hanako))


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int n, m, vis[100001];
vi G[100001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    deque<int> dq;
    dq.push_back(1);
    vis[1] = 1;
    int a = 0, b = 0;
    for (; a < sz(G[dq[0]]); ++a) {
        int v = G[dq[0]][a];
        if (!vis[v]) {
            vis[v] = 1;
            dq.push_front(v);
            a = -1;
        }
    }
    assert(sz(dq) > 1);
    for (; b < sz(G[dq.back()]); ++b) {
        int v = G[dq.back()][b];
        if (!vis[v]) {
            vis[v] = 1;
            dq.push_back(v);
            b = -1;
        }
    }

    cout << sz(dq) << endl;
    rep(i, sz(dq))cout << dq[i] << (i != sz(dq) - 1 ? ' ' : '\n');
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 5e5 + 5;
int m, n, w[N], v[N];
ll dp[N];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) scanf("%d %d", w + i, v + i);
	for (int i = 1; i <= n; ++i) {
		for (int j = m; j >= w[i]; --j) {
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]); 
		}
	}
	ll ans = 0;
	for (int i = 0; i <= m; ++i) ans = max(ans, dp[i]);
	cout << ans;
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
	string S;
    cin >> S;
    bool check = false;
    for(int i=0;i<3;i++){
        if(S[i] == S[i+1]) check = true;
    }
    if(check) cout << "Bad" << endl;
    else cout << "Good" << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 3e2 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	ll n, k;
	cin >> n >> k;
	if (!k)
		f(n * n);
	ll ans = 0;
	lp(i,k+1,n)
	{
		ans += (i - k);
		ans += (1LL * ((n / i) - 1) * (i - k));
		ll z = (n % i) - (k - 1);
		ans += max(0LL, z);
	}
	f(ans);
	return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1148&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	int N,M;

	while(cin >> N >> M && N)
	{
		vector<int> PC(N+1,0);
		vector<vector<int> > record(M+1,vector<int>(1261,0));

		int R;
		cin >> R;
		rep(nth,R)
		{
			int t,n,m,s;
			cin >> t >> n >> m >> s;
			if(s == 1){
				PC[n] = t;
			}else{
				int ts = PC[n];
				REP(i,ts,t){
					record[m][i] = 1;
				}
				PC[n] = 0;
			}
		}

		int Q;
		cin >> Q;
		rep(nth,Q)
		{
			int ts, te, m;
			cin >> ts >> te >> m;
			int ans=0;
			REP(i,ts,te){
				if(record[m][i]){ ans+=1; }
			}
			cout << ans << endl;
		}
	}

	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  string S1 = S.substr(0, (N / 2));
  string S2 = S.substr((N / 2), (N / 2));
  if (N % 2 == 0) {
    if (S1.compare(S2) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int dx=tx-sx, dy=ty-sy;
  rep(i,dx) cout << 'R';
  rep(i,dy) cout << 'U';
  rep(i,dx) cout << 'L';
  rep(i,dy) cout << 'D';
  cout << 'D';
  rep(i,dx+1) cout << 'R';
  rep(i,dy+1) cout << 'U';
  cout << 'L';
  cout << 'U';
  rep(i,dx+1) cout << 'L';
  rep(i,dy+1) cout << 'D';
  cout << 'R';
  cout << endl;
}


Measured memory_bytes: 3608
num = input().split()
nums = []
for i in num:
  nums.append(int(i))
#print(nums)
price = [300000, 200000, 100000]
result = []

#2 3 4 5 6
for i in nums:
  if int(i) > 3:
    result.append(0)
  else:
    result.append(price[i-1])
value = result[0] + result[1]
if value == 600000:
  print("1000000")
else:
  print(value)

Measured memory_bytes: 3064