akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];

	VI ans;
	map<int, int>mp;
	
	for (int i = N; i > 0; i--) {

		int cnt = 0;

		for (int j = i; j <= N; j += i) {
			cnt += mp[j];
		}
		if (cnt % 2 != A[i - 1]) {
			mp[i]++;
			ans.push_back(i);
		}


	}
	SORT(ans);
	cout << ans.size() << endl;
	REP(i, ans.size()) {
		cout << ans[i];
		if (i != ans.size() - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}

	//cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 15732
#include <stdio.h>
int main(){
  int t=0;
  int r[3]={0,0,0};
  char s[3][101];
  for(int i=0;i<3;i++)scanf("%s",&s[i]);
  while(1){
    if(s[t][r[t]]=='a'){
      r[t]++;
      t=0;
    }else if(s[t][r[t]]=='b'){
      r[t]++;
      t=1;
    }else if(s[t][r[t]]=='c'){
      r[t]++;
      t=2;
    }else if(s[t][r[t]]=='\0'){
      break;
    }
  }
  if(t==0)puts("A");
  if(t==1)puts("B");
  if(t==2)puts("C");
  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 main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B){
        if(A!=C){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(A==C){
        if(A!=B){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(B==C){
        if(B!=A){
            cout<<"Yes"<<endl;
            return 0;
            }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
lst = list(map(int, input().split())) + [0]*k
ans = [float('inf')]*(n+k)
ans[0] = 0

def dp():
  for i in range(n):
    for j in range(1, k+1):
      ans[i+j] = min(ans[i+j], ans[i] + abs(lst[i+j]-lst[i]))

dp()

print(ans[n-1])

Measured memory_bytes: 56032
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,L;
    cin>>N>>L;
    vector<int> a(N);
    ll sum = 0;
    REP(i,N){
        cin>>a[i];
        sum += a[i];
    }
    bool flg=false;
    int idx=0;
    REP(i,N-1){
        if(a[i]+a[i+1]>=L) flg=true,idx=i;
    }
    if(flg){
        cout<<"Possible"<<endl;
        for(int i=0;i<idx;i++) cout<<i+1<<endl;
        for(int i=N-1;i>idx+1;i--) cout<<i<<endl;
        cout<<idx+1<<endl;
    }
    else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 1280
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<class T>T gcd(T a, T b) {if(b==0) return a; return gcd(b, a%b);}
template<class T>T lcm(T a, T b) {return a*b/gcd(a, b);}

ll make(ll n, int k){
    map<ll, int> res;
    if(n%2==0){
        while(n!=1 && n%2==0){
            res[2]++;
            n/=2;
        }
    }

    for(ll i=3; i*i<=n; i+=2){
        while(n!=1 && n%i==0){
            res[i]++;
            n /= i;
        }
    }

    if(n!=1) res[n]++;

    ll ans = 1;
    for(auto p: res){
        if(p.second >= k) {
            int t = p.second / k;
            ans *= (ll)pow(p.first, t);
        }
        // cout << p.first << " " << p.second << endl;
    }

    return ans;
}

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

    pr(make(p, n));
    return 0;}

Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a > 9 || b > 9){
			System.out.println(-1);
		}else{
			System.out.println(a * b);
		}
	}

}

Measured memory_bytes: 23764
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <queue>
#include <set>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using V = vector<int>;
using VV = vector<V>;
using P = pair<int, int>;

int main() {
	int dx[] = {4, 2}, dy[] = {2, 4};
	for (int w, h; w = in(), h = in();) {
		P s = {in() - 1, in() - 1}, g = {in() - 1, in() - 1};
		int n = in();
		VV m(h, V(w));
		while (n--) {
			int c = in(), d = in(), x = in() - 1, y = in() - 1;
			for (int i = 0; i < dy[d]; i++)
				for (int j = 0; j < dx[d]; j++)
					m[i + y][j + x] = c;
		}
		auto f = [&]{
			queue<P> q;
			q.push(s);
			int c = m[s.second][s.first];
			set<P> v;
			v.insert(s);
			while (!q.empty()) {
				P t = q.front();
				q.pop();
				if (t == g)
					return "OK";
				P d = {1, 0};
				for (int i = 0; i < 4; i++) {
					P u = {t.first + d.first, t.second + d.second};
					if (u.first >= 0 && u.second >= 0 &&
						u.first < w && u.second < h &&
						m[u.second][u.first] == c && !v.count(u)) {
						v.insert(u);
						q.push(u);
					}
					swap(d.first, d.second *= -1);
				}
			}
			return "NG";
		};
		outl(f());
	}
}


Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int t;cin>>t;
  string s;
  while(t--){
    s+="ACL";
  }
  cout<<s;
  
  return 0;
}
//2020.09.26 20:00:30


Measured memory_bytes: 3580
n, m = gets.split(" ").map(&:to_i)
result = []
m.times do
  p, s = gets.chomp.split(" ")
  result.push([p.to_i, s])
end

penalties = Hash.new(0)
account = Hash.new(0)
wacount = Hash.new(0)

result.each do |r|
  p, s = r
  if s == "WA"
    wacount[p] += 1
  else
    penalties[p] = wacount[p] unless penalties.key?(p)
    account[p] = 1
  end
end

c1 = 0
c2 = 0
account.each { |_, v| c1 += v }
penalties.each { |_, v| c2 += v }
puts "#{c1} #{c2}"

Measured memory_bytes: 28284
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<climits>
#include<queue>
using namespace std;

struct Edge{
		int to;
		int cost;
	};
	
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef pair<int ,int > P;

void dijkstra(Graph &G,vector<int> &d,int r){
	priority_queue < P,vector<P>,greater<P> > que;
	P p;
	d[r]=0;
	que.push(P(r,0));
	
	while(!que.empty()){
		p=que.top();
		que.pop();
		if(p.second>d[p.first]){
			continue;
		}
		d[p.first]=p.second;
		for(int i=0;i<G[p.first].size();i++){
			Edge e = G[p.first][i];
			if(d[e.to]>d[p.first]+e.cost){
				d[e.to] = d[p.first]+e.cost;
				que.push(P(e.to,d[e.to]));
			}
		}
	}
}

int main(){
	int V,E,r;
	cin >> V >> E >> r;
	Graph G(V);
	
	int s;
	for(int i=0;i<E;i++){
		Edge e;
		cin >> s >> e.to >> e.cost;
		G[s].push_back(e);
	}
	
	vector<int> d(V,INT_MAX);
	dijkstra(G,d,r);
	
	for (int i=0;i<V;i++){
		if(d[i]==INT_MAX){
			cout << "INF" << endl;
		}else{
			cout << d[i] << endl;
		}
	}
	return 0;
}

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

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

  vector<int> h(n+1, 0);
  int a;
  for(int i = 1; i <= n; i++){
    cin >> a;
    h[a] = i;
  }

  for(int i = 1; i <= n; i++){
    if(i != 1) cout << " ";
    cout << h[i];
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

struct unionfind {
	vector<int> par, siz;
	unionfind(int N) : par(N), siz(N,1) {
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int root(int x) {
		while(par[x] != x) x = par[x] = par[par[x]];
		return x;
	}
	void unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int size(int x) {
		return siz[root(x)];
	}
};

int main(){
	int n, m; cin >> n >> m;
	unionfind uf(n);
	int x, y, z;
	REP(i,m){
		cin >> x >> y >> z;
		x--; y--;
		uf.unite(x,y);
	}
	vector<bool> f(n,0);
	int ans=0;
	REP(i,n){
		int r=uf.root(i);
		if(!f[r]){
			f[r]=1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

struct RollingHash {
  const int h = 1000000007;
  const int b = 10007;
  vector<int> ha;
  vector<int> po;
  RollingHash(const string &s) {
    int n = (int) s.size();
    ha.assign(n + 1, 0);
    po.assign(n + 1, 0);
    po[0] = 1;
    for (int i = 0; i < n; i++) {
      po[i + 1] = ((long long) po[i] * b) % h;
      ha[i + 1] = ((long long) ha[i] * b + s[i]) % h;
    }
  }
  int get(int l, int r) {
    int ret = ha[r] + h - ((long long) ha[l] * po[r - l]) % h;
    if (ret >= h) ret -= h;
    return ret;
  }
};

struct UnionFind {
  vector<int> par;
  vector<int> siz;
  UnionFind(int n) {
    par = vector<int>(n);
    siz = vector<int>(n, 1);
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
    siz[y] += siz[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  string ss = s;
  while (ss.size() < t.size()) {
    ss += s;
  }
  ss += ss;
  RollingHash sh(ss), th(t);
  auto uf = UnionFind(n);
  for (int i = 0; i < n; i++) {
    if (sh.get(i, i + t.size()) == th.get(0, t.size())) {
      int x = i % n;
      int y = (i + t.size()) % n;
      if (uf.same(x, y)) {
        cout << -1 << endl;
        return 0;
      }
      uf.unite(x, y);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i) - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31412
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 2e6 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
int a[1007];

int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i = 1;i <= n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int sum = 0;
	for(int i = 1;i <= k;i++)
		sum += a[i];
	cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3764
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;

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

    ll N;
    cin >> N;

    vector<char> a(20);

    ll n = 1LL;

    ll c = 0;

    while(n * 26LL + 1LL <= N) {
        n *= 26LL;
        n++;
        cerr << n << endl;
        c++;
    }

    N -= n;
    
    cerr << N << endl;

    int i = 0;

    while(N > 0LL) {
        a[i] = (N % 26LL);
        N /= 26LL;
        i++;
    }

    for(int j = c; j >= 0; j--) {
        cout << char(a[j] + 'a');
    }

    cout << endl;
}

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

int main(void){
    int n, m;
    vector <int> a, b;
    int i;
    int x;
    int ans[60] = {0};
    
    cin >> n >> m;
    
    for(i = 0; i < m; i++){
        cin >> x;
        a.push_back(x);
        cin >> x;
        b.push_back(x);
    }
    
    for(i = 0; i < m; i++){
        ans[a[i]]++;
        ans[b[i]]++;
    }
    
    for(i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,c=0;
    char s[3];
    for(i=0;i<3;i++){
        scanf("%c",&s[i]);
        if(s[i]=='o'){
            c++;
        }
    }
    printf("%d\n",700+(c*100));
    return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define N 2002002
using namespace std;

int n;
string s;
int power1[N],power2[N];  

void precompute(int cnt){
    int k = cnt - 1;
    if(k != 0){
        power1[n - 1] = 1 % k;  
        for (int i = n - 2; i >= 0; i--)  
        {  
            power1[i] = (power1[i + 1] % k) * (2 % k);  
            power1[i] %= k;  
        }
    } 
    k = cnt + 1;
    power2[n - 1] = 1 % k;  
    for (int i = n - 2; i >= 0; i--)  
    {  
        power2[i] = power2[i + 1] * (2 % k);  
        power2[i] %= k;  
    }
}

int getmod1(string str, int n, int k)  
{  
    int res = 0;  
    int i = 0, j = n - 1;  
    while (i < n && j >= 0)  
    {  
        if (str[j] == '1')  
        {
            res += (power1[j]);  
            res %= k;  
        }  
        i++;  
        j--;  
    }  
    return res;  
}
int getmod2(string str, int n, int k)  
{  
    int res = 0;  
    int i = 0, j = n - 1;  
    while (i < n && j >= 0)  
    {  
        if (str[j] == '1')  
        {
            res += (power2[j]);  
            res %= k;  
        }  
        i++;  
        j--;  
    }  
    return res;  
}
int count(int n){
    int cnt = 0;
    while(n > 0){
        cnt++;
        n = n % (__builtin_popcountll(n) );
    }
    return cnt;
}

int32_t main()
{
    cin >> n;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < n; i++)
        cnt += (s[i] == '1');
    precompute(cnt);
    int k1,k2;
    if(cnt - 1 != 0)
    k1 = getmod1(s,n,cnt - 1);
    k2 = getmod2(s,n,cnt + 1);
    if(cnt - 1 == 0)k1 = 0;
    int temp1 = k1;
    int temp2 = k2;
    for(int i = 0; i < n; i++)
    {
        if(cnt - 1 == 0 && s[i] == '1'){
            cout << "0\n";
            continue;
        }
        int ans = 0;
        k1 = temp1,k2 = temp2;
        if(s[i] == '1'){
            k1 -= power1[i];
            if(cnt - 1 > 0)
                while(k1 < 0)k1 += (cnt - 1);
            ans = count(k1);
        }
        else{
            k2 += power2[i];
            k2 %= (cnt + 1);
            ans = count(k2);
        }

        cout << ans + 1 << '\n' ;
    }
    return 0;
}


Measured memory_bytes: 6964
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {
	
	int w, h;
	int[][] W, B;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		
		for(;;) {
			w = sc.nextInt();
			h = sc.nextInt();
			if( (w|h) == 0 ) break;
			
			W = new int[h+2][w+2];
			B = new int[h+2][w+2];
			
			for(int[] a: W) fill(a, 1);
			for(int[] a: B) fill(a, -1);
			
			boolean flg = false;
			for(int i=1;i<=h;i++) {
				String str = sc.next();
				for(int j=1;j<=w;j++) {
					if( str.charAt(j-1) == 'W' ) { flg = true; W[i][j] = B[i][j] = 1; }
					else if( str.charAt(j-1) == 'B' ) { flg = true; W[i][j] = B[i][j] = -1;}
					else W[i][j] = B[i][j] = 0;
				}
			}
			
			int wc = 0, bc = 0;
			
			if(flg)
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) {
				int c = 0;
				if( W[i][j] == 0 ) c = dfs(j,i,1, W);
				if(c != 0) debug( j, i, c, "W" );
				wc += max(c, 0);
				c  = 0;
				if( B[i][j] == 0 ) c = dfs(j,i,-1, B);
				if(c != 0) debug(j, i, c, "B");
				bc += max(c, 0);
			}
			
///			for(int[] a: W) debug(a);
//			for(int[] a: B) debug(a);
			
			System.out.println(bc + " " + wc);
		}
	}
	
	int[] dx = {-1,0,1,0};
	int[] dy = {0,-1,0,1};
	
	int dfs(int x, int y, int c, int[][] map) {
		if( map[y][x] == -c ) return -1;
		map[y][x] = c;
		
		int cnt = 1;
		for(int i=0;i<4;i++) if( map[y+dy[i]][x+dx[i]] != c ) {
			int cc = dfs(x+dx[i], y+dy[i], c, map);
			if( cc == -1 ) {cnt = -1; }
			if( cnt != -1 ) cnt += cc;
		}
		
		return cnt;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	void debug( Object... o ) {
//		System.err.println(deepToString(o));
	}
	
}

Measured memory_bytes: 13000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

// intのpairの型を定義しておく
typedef pair<int, int> P;

// 昇順sort時に使う比較関数, 配列から2つのpair要素を取り出して、secondの値を比較する
bool pairCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}

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

    vector<P> vec(M);

    int a,b;
    for(int i=0; i < M; i++) {
        cin >> a >> b;
        vec[i].first = a;
        vec[i].second = b;
    }

    // 昇順ソート
    sort(vec.begin(), vec.end(), pairCompare);

    int ans = 0;
    int tmp = 0;
    for(int i=0; i < M; i++) {
        if(tmp < vec[i].first) {
            ans++;
            tmp = vec[i].second - 1;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
X, Y = map(int, input().split())
mod = 10**9 + 7

if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    n2x = (2*X - Y) // 3
    n1x = (2*Y - X) // 3
    n = n2x + n1x

    # nCn2xを求める
    def combs(n,n2x,mod):
        facs = [1] * (n+1)
        # invs = [1] * (n+1)
        nfac = 1
        for i in range(1, n+1):
            nfac = nfac * i % mod
            facs[i] = nfac
            # invs[i] = pow(nfac, mod-2, mod)
        return nfac * (pow(facs[n2x], mod-2, mod) * pow(facs[n-n2x], mod-2, mod)) % mod

    print(combs(n, n2x, mod))

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;
vint G[2000];
int A[2000],B[2000];

int dep[2000];
void dfs(int v,int p,int d){
    dep[v]=d;
    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v,d+1);
    }
}

signed main(){
    cin>>N>>K;
    rep(i,N-1){
        cin>>A[i]>>B[i];
        A[i]--;B[i]--;
        G[A[i]].pb(B[i]);
        G[B[i]].pb(A[i]);
    }
    int ans=1001001001;
    if(K&1){
        rep(i,N-1){
            dfs(A[i],B[i],0);
            dfs(B[i],A[i],0);
            int cnt=0;
            rep(j,N)if(dep[j]>(K-1)/2)cnt++;
            chmin(ans,cnt);
        }
    }
    else{
        rep(i,N){
            dfs(i,-1,0);
            int cnt=0;
            rep(j,N)if(dep[j]>K/2)cnt++;
            chmin(ans,cnt);
        }
    }

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


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

int main()
{
   string s;
   cin>>s;
   ll n;
   n=s.length();
   ll i,c=0,d=0;
   for(i=0;i<n;i++)
   {
      if(i%2==0)
      {
         if(s[i]=='R'||s[i]=='U'||s[i]=='D')
            c++;
            else d++;
      }
      else
      {
         if(s[i]=='L'||s[i]=='U'||s[i]=='D')
            c++;
            else d++;

      }
   }
   if(c==n)
   {
      cout<<"Yes";
      return 0;
   }
   else
   {
      cout<<"No";
      return 0;
   }
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[144];
    Scs(s);
    s[strlen(s)-8] = 0;
    printf ("%s\n", s );

    return 0;
}





Measured memory_bytes: 256
import sys
from itertools import dropwhile
a = []
for v in sys.stdin:
    a.append(int(v))

m = max([a.count(v) for v in set(a)])
try:
    next(dropwhile(lambda x: True, (print(v) for v in set(a) if a.count(v) == m)))
except StopIteration:
    pass

Measured memory_bytes: 7596
#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 mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 900010
ll f[M],iv[M];
ll ex(ll a,ll b){
	ll ans=1;a%=md;
	while(b){
		if(b&1)ans=(ans*a)%md;
		a=(a*a)%md;b/=2;
	}
	return ans;
}
ll C(ll n,ll r){
	if(n<r)return 0;
	ll ans=(f[n]*iv[r])%md;
	ans=(ans*iv[n-r])%md;
	return ans;
}
ll g(ll n,ll k){
	ll ans=1;
	rep(i,0,k)ans=(ans*(n-i))%md;
	ans=(ans*iv[k])%md;
	return ans;
}
int main(){
	IOS;
	tihs;
	
	f[0]=1,iv[0]=1;
	rep(i,1,M)f[i]=(i*f[i-1])%md;
	iv[M-1]=ex(f[M-1],md-2);
	for(ll i=M-2;i>=0;--i)iv[i]=(iv[i+1]*(i+1))%md;

	ll n,k;cin>>n>>k;
	ll ans = 0;
	rep(i,0,min(n+1,k+1)){
		ll a = C(i+n-i-1,n-i-1);
		ll b = C(n,i);
		ll c = a*b%md;
		(ans+=c)%=md;
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 14336
/**   
 *   Author:    @glaucoacassioc
 *   Created on 11.09.2020, 15:32:16
**/
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
vector<vii> AdjList;

vi pai, color, dist, ts;

int main()
{
//	freopen("in.txt","r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, ans, sum = 0, cont=0;

	cin >> n >> m;
	vi v(n);
	for(int i=0; i < n; i++)
	{
		cin >> v[i];
		sum+= v[i];
	}
	ans = 4 * m;
	bool popular = false;
	for(int i=0; i<n; i++)
	{
		if(1LL * v[i] * ans >= sum) cont++;
		if(cont==m)
		{ 
			popular=true;
			break;
		}
	}
	popular ? cout << "Yes\n" : cout << "No\n";

	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
using ll = unsigned long long;
ll u18 = 1000000000000000000;
int main()
{
    
    double b;
    ll a, bb ;
    cin >> a >> b ;

    b = round( b*100. );
    bb = (ll)b;
    a  *= bb;
    a /= 100;
    cout << a << endl;

   
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;


int main(){
  ll S;
  cin >> S;
  //x1y2-x2y1=S
  //x1*1e9-y1=S
  //(S+y1)/1e9=x1

  ll x1,y1;
  y1 = (1000000000-(S%1000000000))%1000000000;
  x1 = (S+y1)/1000000000;

  cout << x1 << " " << y1 << " " << 1 << " " << 1000000000 << " " << 0 << " " << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); //偶数の個数
    int M = sc.nextInt(); //奇数の個数
    //偶数になるのは奇数+奇数もしくは偶数+偶数
    //奇数+奇数の場合N_C_2
    int count_1 = N*(N-1)/2;
    //偶数+偶数の場合M_C_2
    int count_2 = M*(M-1)/2;
    
    System.out.println( count_1 + count_2);
    
    
  }
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

// ================================================= //

/*
 update : [s,t) に xを加算
 query  : [s,t) の　最大(小)値を出力する
 */

/* [0..N-1] */
const ll INIT = 0; // 問題に合わせる
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node, lazy;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
        lazy.resize(2 * N - 1, init_v);
    }
    
    void lazy_evaluate(int k) {
        if (k >= N - 1)node[k] += lazy[k];
        if (k < N - 1) {
            lazy[2 * k + 1] += lazy[k] / 2;
            lazy[2 * k + 2] += lazy[k] / 2;
        }
        lazy[k] = 0;
    }
    
    /* [a,b) 引数の範囲に注意!! s~tまでを更新→update(s,t+1,~) */
    void update(int a, int b, int x) { update(a, b, 0, 0, N, x); }
    void update(int a, int b, int k, int l, int r, int x) {
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] += (r - l)*x;
            lazy_evaluate(k);
        }
        else {
            lazy_evaluate(k);
            update(a, b, 2 * k + 1, l, (l + r) / 2, x);
            update(a, b, 2 * k + 2, (l + r) / 2, r, x);
        }
    }
    
    /* [a,b) 引数の範囲に注意!! */
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) {
            lazy_evaluate(k);
            return node[k];
        }
        else {
            lazy_evaluate(k);
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
};

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    
    SegTree ST(n);
//    BIT bit(n);
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t,x; cin >> s >> t >> x;
            ST.update(s-1,t,x);
        }else{
            int i; cin >> i;
            cout << ST.query(i-1,i) << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 7060
#include<stdio.h>

int main(void){
	int N;
	int ans=0;
	
	scanf("%d",&N);
    
	for(int i=1;i<N;i++){
		if(N%i==0){
			ans+=N/i-1;
		}
		else{
			ans+=N/i;
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
//#define pai 3.14159265

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
  int A, B, H, M;
  long double tha, thb, dis;
  cin >> A >> B >> H >> M;
  const double PI=3.14159265358979323846264338327950L;

  long double time = (long double)H * 60 + (long double)M;
  tha = 360.0 - (time /2) + 90.0;
  thb =360.0 - ((long double)M * 6) + 90.0 ;

/*   if (tha > 360) tha -= 360;
  if (thb > 360) thb -= 360; */

  long double rada = tha * PI / 180.0;
  long double radb = thb * PI / 180.0;


  dis = pow(((long double)A * cosl(rada) - (long double)B * cosl(radb)), 2) + pow(((long double)A * sinl(rada) - (long double)B * sinl(radb)), 2);
  cout << setprecision(18) << sqrtl(dis)  << endl; 
  //cout << tha << endl;
  //cout << thb << endl;
  //cout << rada << endl;
  //cout << radb << endl;
  //cout << cos(PI/2) << endl;


  return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  vector<T> dat;
  // 要素数、結合演算、作用素の適用演算、台集合の単位元、初期値
  SegmentTree(int n_,F f,G g,T d1,
        vector<T> v=vector<T>()){
    this->f=f;
    this->g=g;
    this->d1=d1;
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  T query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(int a,int b){
    return query(a,b,0,0,n);
  }
};

ll N;
ll A[4001];
ll dp[2][4001];
ll pre[4001][4001];
ll sum[4001];

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

  cin>>N;
  rep(i,N)cin>>A[i];
  rep(i,N){
    sum[i+1]=sum[i]+A[i];
  }
  rep(i,2)rep(j,N+1){
    dp[i][j]=INF;
  }
  rep(i,N+1)rep(j,N+1){
    pre[i][j]=-1;
  }
  ll crt=0,nxt=1;
  dp[crt][0]=-INF;
  ll ans=0;
  rep(i,N){
    SegmentTree<P,P> sgt(N+1,[](P a,P b){return min(a,b);},[](P a,P b){return b;},P(INF,INF));
    vector<P> vs;
    rep(j,N+1){
      vs.push_back(P(dp[crt][j]+sum[j],j));
      dp[nxt][j]=INF;
    }
    sort(all(vs));
    rep(j,N+1){
      ll k=lower_bound(all(vs),P(sum[j],-INF))-vs.begin();
      P p=sgt.query(0,k);
      if(p.fi!=INF){
        if(j==N){
          ans=i+1;
        }
        dp[nxt][j]=p.fi+sum[j];
        pre[i+1][j]=p.se;
      }

      k=lower_bound(all(vs),P(dp[crt][j]+sum[j],j))-vs.begin();
      sgt.update(k,P(-sum[j],j));
    }
    swap(crt,nxt);
  }
  P crtp=P(ans,N);
  vector<ll> res;
  while(P(crtp.fi-1,pre[crtp.fi][crtp.se])!=P(-1,-1)){
    res.push_back(crtp.se);
    crtp=P(crtp.fi-1,pre[crtp.fi][crtp.se]);
  }
  reverse(all(res));
  cout<<ans<<endl;
  if(res.size()>1){
    cout<<res[0];
    repl(i,1,res.size()-1)cout<<" "<<res[i];
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 128684
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n, m; cin >> n >> m;
    ll a[m];
    rep(i, m){
        cin >> a[i];
    }

    ll d_work = accumulate(a, a + m, 0LL);

    if(d_work > n){
        cout << -1 << endl;
    }
    else{
        cout << n - d_work << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#ABC061B
N,M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ans =[]
for i in range(1,N+1):
    count=0
    for j in range(M):
        if ab[j][0] ==i:
            count +=1
        if ab[j][1] ==i:
            count +=1
    ans.append(count)
for a in ans:
    print(a)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, A;
	cin >> N >> A;
	cout << N * N - A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    lint ans=10000000000;
    for(int i=0;i<=2*max(x,y);i+=2){
        lint tmp=0;
        tmp+=c*i;
        tmp+=a*max(x-i/2,0);
        tmp+=b*max(y-i/2,0);
        if(tmp<ans)ans=tmp;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
     
    public static void main(String[] args) {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String str = reader.readLine();
            String[] arr = str.split(" ");
            int a = Integer.parseInt(arr[0]);
            int b = Integer.parseInt(arr[1]);
            int c = Integer.parseInt(arr[2]);
            int temp;
             
            if (a > b) {
                temp = a;
                a = b;
                b = temp;
            }
             
            if (b > c) {
                temp = b;
                b = c;
                c = temp;
            }
             
            if (a > b) {
                temp = a;
                a = b;
                b = temp;
            }
             
            System.out.println(a + " " + b + " " + c);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
}

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

int main()
{
    int k;
    cin >> k;
    long long int s = 0;
    for (long long int a = 1; a <= k; a++)
        for (long long int b = 1; b <= k; b++)
            for (long long int c = 1; c <= k; c++)
                s += __gcd(c, __gcd(a, b));
    cout<<s;
}

Measured memory_bytes: 3636
object Main {
    def spin(v : (Int, Int)) : (Int, Int) = {
        (-1 * v._2, v._1)
    }
    def add (v1 : (Int, Int), v2: (Int, Int)) : (Int, Int) = {
        (v1._1 + v2._1, v1._2 + v2._2)
    }
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val x1, y1, x2, y2 = sc.nextInt 
        val v = (x2 - x1, y2 - y1)
        val (x3, y3) = add(spin(v), (x2, y2))
        val (x4, y4) = add(spin(spin(v)), (x3, y3))
        println(s"${x3} ${y3} ${x4} ${y4}")
    }
}


Measured memory_bytes: 25536
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
#define N 500005
#define Q 500005
struct node{
	int n, x, y;
}l[Q*2];
int n, cnt, q, a[N], f[N], last[N], g[N*10], ans[Q];
bool cmp(node a, node b){return a.x<b.x;}
void upd(int t, int l, int r, int x){
	if (l==r) {
		g[t]++;
		return;
	}
	int mid=l+r>>1;
	if (x<=mid) upd(t<<1, l, mid, x);
	else upd((t<<1)+1, mid+1, r, x);
	g[t]=g[t<<1]+g[(t<<1)+1];
}
int query(int t, int l, int r, int ri){
	if (r<=ri) return g[t];
	int mid=l+r>>1;
	int tmpl=query(t<<1, l, mid, ri), tmpr=0;
	if (ri>mid) tmpr=query((t<<1)+1, mid+1, r, ri);
	return tmpl+tmpr;
}
int main(){
	n=read(), q=read();
	for (int i=1;i<=n;i++) {
		a[i]=read();
		f[i]=last[a[i]];
		last[a[i]]=i;
	}
	for (int i=1;i<=q;i++){
		int le=read()-1, ri=read();
		l[++cnt].x=ri;
		l[cnt].y=le;
		l[cnt].n=i;
		ans[i]-=le;
	}
	sort(l+1,l+1+cnt,cmp);
	for (int i=1, j=1;i<=n && j<=q;i++){
		upd(1,1,n+1,f[i]+1);
		for (;j<=q && l[j].x<=i;j++)
			ans[l[j].n]+=query(1,1,n+1,l[j].y+1);
	}
	for (int i=1;i<=q;i++) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 21124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t,c,b,m=1001;
  cin>>n>>t;
  for(int i=0;i<n;i++){
    cin>>c>>b;
    if(b<=t)
      m=min(c,m);
  }
  if(m==1001)
    cout<<"TLE";
  else
    cout<<m;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    int N = s.size();
    int nax = pow(10,9);
    for(int i=0; i<N-2; i++){
        string si;
        si = s.substr(i,3);
        chmin(nax, abs(753 - stoi(si)));
    }
    cout << nax << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);





int main(){
   int a,b;
   cin>>a>>b;
   cout<<a*b<<endl;
}


 
    



    



    
    
    




    


    

    






    
    

    
 
    
 

 
 
    
 
 


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

dic = {}
for i in range(1,10):
  for j in range(1,10):
    dic[(str(i),str(j))] = 0

for i in range(N+1):
  nstr = str(i)
  pre = nstr[0]
  suf = nstr[-1]
  if suf == '0':
    continue
  dic[(pre, suf)] =dic[(pre, suf)] + 1

cnt = 0 
for i in range(1,10):
  for j in range(1,10):
    cnt += dic[(str(i),str(j))] * dic[(str(j),str(i))]

print(cnt)

Measured memory_bytes: 3064
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

using namespace std;

int n;
int a[100005];
long long sum[100005];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+abs(a[i]-a[i-1]);
	}
//	for(int i=1;i<=n;i++) printf("%I64d ",sum[i]);
//	puts("");
	printf("%I64d\n",abs(a[2])+(sum[n]-sum[2])+abs(a[n]));
	for(int i=2;i<n;i++){
		long long ans=abs(a[i+1]-a[i-1])+sum[i-1]+(sum[n]-sum[i+1])+abs(a[n]);
		printf("%I64d\n",ans);
	}
	printf("%I64d\n",sum[n-1]+abs(a[n-1]));
	return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a(n);
    loop(i, n) cin >> a[i];
    vec b(n);
    loop(i, n) b[i] = a[i] - i - 1;
    sort(all(b));
    ll mid;
    if (n % 2 == 0)
        mid = (b[n / 2 - 1] + b[n / 2]) / 2;
    else
        mid = b[n / 2];
    ll ans = 0;
    loop(i, n) ans += abs(b[i] - mid);
    putout(ans);
    return 0;
}

Measured memory_bytes: 3328