akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int mod=998244353;
int main(){
    ll n,m;cin>>n>>m;
    vector<ll>x(n);
    rep(i,n)cin>>x[i];
    sort(all(x));
    vector<ll>r(m);
    vector<ll>p(m);
    x.pb(0);
    rep(i,n){
        if(x[i]==x[i+1]){
            p[x[i]%m]+=2;
            r[x[i]%m]+=2;
            i++;continue;
        }
        r[x[i]%m]++;
    }
    ll ans=0;
    ans+=r[0]/2;
    if(!(m%2))ans+=r[m/2]/2;
    REP(i,1,(m+1)/2){
        ll a=p[i],b=p[m-i],c=r[i]-a,d=r[m-i]-b;
        if(c>=d){
            ans+=d;
            c-=d;
            if(c>=b){
                ans+=b;
                ans+=a/2;
            }else{
                ans+=c;
                b-=c;
                ans+=b/2;
                ans+=a/2;
            }
        }else{
            swap(c,d);
            swap(a,b);
            ans+=d;
            c-=d;
            if(c>=b){
                ans+=b;
                ans+=a/2;
            }else{
                ans+=c;
                b-=c;
                ans+=b/2;
                ans+=a/2;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

		List<Integer> B = new ArrayList<Integer>();

		for (int i=0; i<m; i++){
			B.add(Integer.parseInt(sc.next()));
		}

		int ans = 0;
		for (int j=0; j<n; j++){
			int sum = c;
			for (int k=0; k<m; k++){
				sum += Integer.parseInt(sc.next()) * B.get(k);
			}
			if (sum > 0){
				ans += 1;
			}
		}
		System.out.println(ans);
	}
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if((max({a,b,c})*3-a-b-c)%2==0) {
    cout << (((max({a,b,c}))*3-a-b-c)/2) << endl;
  }
  else {
    cout << (((max({a,b,c}))*3-a-b-c)/2+2) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int W,a,b,maxi,mini;

int main(){
    string A,B;
    cin >> A >>B;
    a=A.size();
    b=B.size();
    for(int i=0;i<min(a,b);i++)
    {
        cout << A[i]<< B[i];
    }
    for(int i=min(a,b);i<max(a,b);i++)
    {
        if(a>b)
        {
            cout<<A[i];
        }
        else
        {
            cout<<B[i];
        }
    }
}
    
    
    
    

  

Measured memory_bytes: 384
#include<stdio.h>

int main(){
	long long N,K,sum=0,ans=-1;
	scanf("%lld%lld",&N,&K);
	long long a[N],b[N];
	for(long long i=0;i<N;i++)scanf("%lld%lld",&a[i],&b[i]);
	
	long long h=N;
	long long swapped=0;
	while(h>1 || swapped==1){
		if(h>1)h=h*10/13;
		swapped=0;
		for(long long i=0;i<N-h;i++){
			if(a[i]>a[i+h]){
				long long tmp=a[i];
				a[i]=a[i+h];
				a[i+h]=tmp;
				tmp=b[i];
				b[i]=b[i+h];
				b[i+h]=tmp;
				swapped=1;
			}
		}
	}
	
	for(long long i=0;i<N;i++){
		sum+=b[i];
		if(sum>=K && ans==-1)ans=i;
	}
	printf("%lld\n",a[ans]);
	return 0;
}

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

using namespace std; 
  int main()
  {
      int n,k;
      cin>>n>>k;
      int i,j;
     long long int a[n];
     long long int dp[n];
      for(i=0;i<n;i++)
      {
          cin>>a[i];
      }
      for(i=0;i<n;i++)
      {
          dp[i]=1e16;
      }
      dp[0]=0;
      dp[1]=abs(a[1]-a[0]);
      for(i=2;i<n;i++)
      {
         for(j=i-1;j>=i-k&&j>=0;j--)
         {
             dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
         }
      }
      cout<<dp[n-1]<<endl;

      
      return 0;
  }

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int n, m, x[1000000];
long long sum1, sum2;
int main() {
	while (true) {
		sum1 = 0; sum2 = 0;
		cin >> n >> m;
		if (n == 0 && m == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> x[i];
			sum1 += x[i];
		}
		sort(x, x + n);
		for (int i = n - m; i >= 0; i -= m) {
			sum2 += x[i];
		}
		cout << sum1 - sum2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("YES");
	else say("NO");
}

int main() {
	makei(A);
	makei(B);
	int t = A + B;
	if (t >= 24)t -= 24;
	say(t);
}

Measured memory_bytes: 256
package main
import (
	"fmt"
  	"sort"
)

type Info struct {
  	idx int
    city string
    val int
}
type Guide []*Info

func newGuide (idx int, city string, val int) (g *Info) {
  g = new(Info)
  g.idx, g.city, g.val = idx, city, val
  return g
}

func (p Guide) Len() int {
  return len(p)
}
func (p Guide) Swap(i, j int) {
  p[i], p[j] = p[j], p[i]
}
func (p Guide) Less(i, j int) bool {
  if (p[i].city < p[j].city) {
    return true
  } else if (p[i].city == p[j].city) {
    if (p[i].val > p[j].val) {
      return true
    }
  }
  return false
}

func main() {
  var n, a int
  var b string
  fmt.Scan(&n)
  
  var info Guide
  for i:=0;i<n;i++ {
    fmt.Scan(&b, &a)
    info = append(info, newGuide(i+1, b, a))
  }
  
  sort.Sort(info)
  
  for i:=0;i<n;i++ {
    fmt.Println(info[i].idx)
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string.h>
using namespace std;

int main()
{

	int n, m;
	long long sum;
	cin >> n >> m;
	sum = (n * (n - 1) + m * (m - 1)) / 2;
	cout << sum << endl;
    
}

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

int main()
{
	while (true){
		int n;
		cin >> n;
		if (!n) break;
		vector<int> line;
		vector<int>::iterator p;
		int max = 0;

		for (int i = 0; i < n; i++){
			int in;
			cin >> in;
			line.push_back(in);
		}

		for (p = line.begin(); p != line.end(); p++){
			for (int i = 1; i <= 3; i++){
				vector<int>::iterator pp, pm;
				pm = p - 1;
				pp = p + 1;
				int now = i, total = 0;
				bool flag = false;

				while (true){
					int chain = 0;
					while (pm != line.begin() - 1 && *pm == now){
						pm--; chain++;
					}
					while (pp != line.end() && *pp == now){
						pp++; chain++;
					}
					if (flag ? (chain >= 4) : (chain >= 3)){
						total += (flag ? chain : chain + 1);
						flag = true;
						if (pm == line.begin() - 1 || pp == line.end()) break;
						now = *pm;
					}
					else break;
				}
				max = (total > max) ? total : max;
			}
		}
		cout << n - max << endl;
	}
	return 0;
}

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


int main(){
  int n,k,q,i,j,m,z;


  cin >> n >> k >> q;

  int *a = new int[q];
  int *b = new int[n];

  for(i=0;i<=q-1;i++){
    cin >> m;
    a[i]=m;
  }
  for(i=0;i<=n-1;i++){
    b[i]=k-q;
  }

  for(i=0;i<=q-1;i++){
    z = a[i];
    b[z-1]=b[z-1]+1;
  }
  for(i=0;i<=n-1;i++){
    if(b[i]>0){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }

  delete[] a;
  delete[] b;

  return 0;
}


Measured memory_bytes: 1408
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[N][j][A * j]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 94812
fn main() {
    let n = read::<usize>();
    let h = read_vec::<u64>();

    let mut ma = 0;
    let mut cnt = 0;
    for i in 0..n-1 {
        if h[i] >= h[i+1] {
            cnt += 1;
            if ma < cnt {
                ma = cnt;
            }
        } else {
            cnt = 0;
        }
    }

    println!("{}", ma);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

int main(){
    int x, n, ans = 0;
    cin >> x >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i <= 101; i++){
        bool f = false;
        for(int j = 0; j < n; j++){
            if(i == p[j]){
                f = true;
                break;
            }
        }
        if(f == true) continue;
        if(abs(i - x) < abs(ans - x)){
            ans = i;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  REP(i,n){
    cin >> a[i];
    sum += a[i];
  }
  vector<ll> x(n);
  x[0] = sum;
  for(int i=1; i < n; i+=2){
    x[0] -= 2*a[i];
  }
  cout << x[0] << " ";
  FOR(i,1,n){
    x[i] = 2*a[i-1] - x[i-1];
    cout << x[i] << " ";
  }
  
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define INF 1LL<<60
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll dp[2005][2005];
ll x[2005];
ll sum[2005];
vector<ll> vec;

void solve(int m,int a,int b,int l,int r){
	if(a==b)return;
	int mid=(a+b)/2;
	//printf("a%d b%d\n",a,b);
	ll ans=INF;
	int best=-1;
	for(int i=l;i<=mid;i++){
		ll cost=dp[m][i];
		cost+=vec[mid]*(mid+1-i);
		cost-=sum[mid+1]-sum[i];
		//printf("%d %d %lld %lld\n",i,mid,vec[mid]*(mid-i),sum[mid+1]-sum[i]);
		if(cost<ans){
			ans=cost;
			best=i;
		}
	}
	dp[m+1][mid+1]=min(ans,dp[m][mid+1]);
	solve(m,a,mid,l,best+1);
	solve(m,mid+1,b,best,r);
}

int main(void){
	int s,n,m;
	scanf("%d%d%d",&s,&n,&m);
	for(int i=0;i<s;i++){
		scanf("%lld",&x[i]);
	}
	for(int i=0;i<n;i++){
		int t,p;
		scanf("%d%d",&t,&p);
		p--;
		vec.push_back(t-x[p]);
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<n;i++){
		sum[i+1]+=sum[i];
		sum[i+1]+=vec[i];
	}
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			dp[i][j]=INF;
		}
		dp[i][0]=0;
	}
	for(int i=0;i<m;i++){
		solve(i,0,n,0,n);
	}
	printf("%lld\n",dp[m][n]);
	return 0;
} 


Measured memory_bytes: 18200
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "YES" : "NO"));}
//----------------------------------------------------------------

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;

  bool ok=false;
  rep(i,b){
    int tmp = a*i;
    if(tmp%b==c) ok=true;
  }

  prtok(ok);
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <iomanip>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

using namespace std;

int main() {
	int a;
	string s;
	cin >> a;
	cin >> s;

	if (a >= 3200) cout << s;
	else cout << "red";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n;
    cin >> n;
    // ll sum = n - 1;
    cout << n-1 + (n-1)*(n-2)/2;
    return 0;
}

Measured memory_bytes: 256
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, x;
      cin >> n >> x;
      lld L[n];
      lld i;
      foi(i,n){
      	cin >> L[i];
      }
      lld pos = 0;
      i = 0;
      lld c = 0;
      while (pos  <= x){
      	pos = pos + L[i];
      	i++;
      	c++;
      }
      cout << c;
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int g[10][10000];
int maxn;
int r, c;
void dfs(int step)
{
	if (step == r)
	{
		int num = 0;
		for (int i = 0; i < c; ++i)
		{
			int res = 0;
			for (int j = 0; j < r; ++j)
				res += g[j][i];
			num += max(res, r - res);
		}
		maxn = max(num, maxn);
	}
	else
	{
		dfs(step + 1);
		for (int j = 0; j < c; ++j)
			g[step][j] = !g[step][j];
		dfs(step + 1);
	}
}
int main()
{
	while (cin >> r >> c&&r&&c)
	{
		for (int i = 0; i < r; ++i)
			for (int j = 0; j < c; ++j)
				cin >> g[i][j];
		maxn = 0;
		dfs(0);
		cout << maxn << endl;
	}
	return 0;
}

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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if(u == s) --a;
    else if(u == t) --b;

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
/******************
*  Writer: Oh no  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	if(s[0]!='A'){
		cout<<"WA";
		return 0;
	}
	s.erase(0,1);
	if(s[0]<'a'||s[0]>'z'){
		cout<<"WA";
		return 0;
	}
	s.erase(0,1);
	if(s[s.size()-1]<'a'||s[s.size()-1]>'z'){
		cout<<"WA";
		return 0;
	}
	s.erase(s.size()-1,1);
	int cnt;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			cnt++;
		}else{
			if(s[i]<'a'||s[i]>'z'){
				cout<<"WA";
				return 0;
			}
		}
	}
	if(cnt==1){
		cout<<"AC";
	}else{
		cout<<"WA";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<cstdio>
using namespace std;
void InsertionSort(int a[],const int n,const int g,int *cnt){
    for(int i=g;i<n;++i){
        int tmp=a[i];
        int j=i-g;
        while(j>-1 && tmp<a[j]){
            a[j+g]=a[j];
            j=j-g;
            ++*cnt;
        }
        a[j+g]=tmp;
    }
}
void ShellSort(int a[], const int n){
    int cnt = 0;
    int m;
    int G[100];
    for(int i=0;i<100;++i){
        if(i==0){
            G[i]=n/2+1;
        }else{
            G[i]=G[i-1]/2-1;
        }
        if(G[i]<0){
            G[i-1]=1;
            G[i]=0;
            m=i;
            break;
        }
    }
    for(int i=0;i<m;++i){
        InsertionSort(a,n,G[i],&cnt);
    }
    printf("%d\n",m);
    for(int i=0;i<m;++i){
        if(i){
            putchar(' ');
        }
        printf("%d",G[i]);
    }
    printf("\n%d\n",cnt);
    for(int i=0;i<n;++i)
        printf("%d\n",a[i]);
}
int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i=0;i<n;++i){
        scanf("%d",&a[i]);
    }
    ShellSort(a,n);
    return 0;
}


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

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

const int INF = 1000000007;

int main(void){
	int r;
	cin>>r;

	if(r < 1200) printf("ABC\n");
	else if(1200 <= r && r < 2800) printf("ARC\n");
	else printf("AGC\n");

	return 0;
}

Measured memory_bytes: 256
//2020-08-26, Wed

#include<iostream>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
        
    return 0;
}

Measured memory_bytes: 3540
fun main(args : Array<String>) {
    val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
    val cake = mutableListOf<String>()

    repeat(h) {
        cake.add(readLine()!!)
    }

    val ans = mutableListOf<String>()
    var num = 1
    var copy = 0
    repeat(h) { hIdx ->
        var row = ""
        var berry = false

        repeat(w) { wIdx ->
            val c = cake[hIdx][wIdx]
            if (c == '#') {
                if (berry) num++
                berry = true
            }
            row += "$num "
        }

        if (!berry) {
            ans.add("")
            copy++
        }  else {
            ans.add(row)
            num++

            for (i in hIdx-copy until hIdx) {
                ans[i] = row
            }
            copy = 0
        }
    }

    if (copy > 0) {
        for (i in h-copy until h) {
            ans[i] = ans[h-copy-1]
        }
    }

    ans.forEach { println(it.dropLast(1)) }
}

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

using namespace std;

#define ll long long
#define mod 1000000007

const ll INF = 1e11;

void solve(){

    ll n, k; cin >> n >> k;
    ll arr[n];
    for(int i = 0; i < n; ++i)
        cin >> arr[i];
    ll l = 1, r = *max_element(arr, arr+n);
    while(l < r){
        ll mid = l + (r-l)/2;
        ll cuts = 0;
        for(ll i = 0; i < n; ++i)
            cuts += (arr[i]-1)/mid;
        if(cuts > k) l = mid + 1;
        else r = mid;
    }
    cout << l << "\n";

    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}

Measured memory_bytes: 5192
<?php
// Your code here!
    $input_line = trim(fgets(STDIN));
    
    $num = explode(" ",$input_line);
    
    $W = intval($num[0]);
    $H = intval($num[1]);
    $x = intval($num[2]);
    $y = intval($num[3]);
    $r = intval($num[4]);
    
    if(($x>=$r)&&($y>=$r)&&($x<=($W-$r))&&($y<=$H-$r)){
        echo "Yes";
    }else{
        echo "No";
    }
    echo "\n";
    

?>


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define sz(a) ll(a.size())
#define trace(c,x) for(auto &x:c)
#define F first
#define S second		
ll mod = 1e9 + 7;   //change acc to question

ll fastexpo(ll x,ll y)
{
	ll a=1;
	while(y>0)
	{
		if(y&1)a = (a*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}	
	return a;
}

ll weight[100005];
ll val[100005];
ll memo[105][100005];

ll dp(int i,int rem)
{
	if(rem<0)
		return -1e9;
	if(i==0)
	{
		if(weight[i]<=rem)
			return val[i];
		else
			return 0;
	}
	if(memo[i][rem]!=-1)
		return memo[i][rem];

	memo[i][rem] =  max(val[i]+dp(i-1,rem-weight[i]),dp(i-1,rem));	
	return memo[i][rem];
}

int main(){

ios::sync_with_stdio(false);

int n,w;
cin>>n>>w;
for(int i=0;i<n;i++)
{
	cin>>weight[i]>>val[i];
}
for(int i=0;i<n;i++)
{
	for(int j=0;j<=w;j++)
		memo[i][j] = -1;
}

cout<<dp(n-1,w)<<endl;

return 0;

}	

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int a[maxn], b[maxn];

int main()
{
	int n, num = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	sort(a + 1, a + 1 + n); 
	for(int i = 0; i < n; i++){
		if(a[i] != b[i]){
			num++;
		}
		if(num > 2){
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

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

cnt=0
for i in range(1000):
  num=str(i).zfill(3)
  if num[0] in s:
    inx1=s.index(num[0])
    s2=s[inx1+1:]
    if num[1] in s2:
      inx2=s2.index(num[1])
      s3=s2[inx2+1:]
      if num[2] in s3:
        cnt+=1
print(cnt)

Measured memory_bytes: 3188
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int BIG_INT = 1000000000;
const ll BIG_NUM = 1000000000000000000;



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

	multiset<int> ms;
	for (int i = 0; i < n; i++) {
		if (ms.size() > 0) {
		
			auto it = ms.upper_bound(-a[i]);

			if (it != ms.end()){
				
				ms.erase(it);
			}
		}

		ms.insert(-a[i]);
	}


	
	cout << ms.size() << endl;
}



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

int main(void) {
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int success = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500*i + 100*j + 50*k == x) {
                    success++;
                }
            }
        }
    }

    cout << success << endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "3 2 10 20", "8 15 13", "16 22" ].parse.expand.solve == "No War" );
	assert( [ "4 2 -48 -1", "-20 -35 -91 -23", "-22 66" ].parse.expand.solve == "War" );
	assert( [ "5 3 6 8", "-10 3 1 5 -100", "100 6 14" ].parse.expand.solve == "War" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmxy = input.front.split.to!( long[] );
	input.popFront;
	auto xs = input.front.split.to!( long[] );
	input.popFront;
	auto ys = input.front.split.to!( long[] );
	return tuple( nmxy[ 2 ], nmxy[ 3 ], xs, ys );
}

auto solve( long x, long y, long[] xs, long[] ys )
{
	auto xm = ( x ~ xs ).reduce!max;
	auto ym = ( y ~ ys ).reduce!min;
	
	return ( xm < ym ) ? "No War" : "War";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) cin >> a[i];
		
	deque<int> d;
	for (int i = 0; i < N;++i) {
		int p = lower_bound(d.begin(),d.end(),a[i])-d.begin();
		if (p == 0) d.push_front(a[i]);
		else d[p - 1] = a[i];
	}

	int ans = d.size();
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int S,h,m,s;
	scanf("%d", &S);
	h = S / (60 * 60);
	m = S % (60 * 60) / 60;
	s = S - h * 60 * 60 - m * 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <string>

int main(){
	std::string N; std::cin >> N;
	unsigned long long int sum{ 0 };
	for (auto i{ 0 }; i < N.length(); ++i) {
		int n = (int)(N[i] - '0');
		sum += n;
		sum %= 9;
	}

	if (sum % 9 == 0) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) {
    return s << '<' << P.first << ", " << P.second << '>';
}
template<class T> ostream& operator << (ostream &s, vector<T> P) {
    for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl;
}
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) {
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl;
}
template<class T> void print(T a, T b) { 
    for (T i = a; i != b; ++i) { if (i != a) { cout << " "; } cout << *i; } cout << endl; 
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



double abs(double x, double y) { return sqrt(x*x+y*y); }
          
int c[40];
int cover[40];
short dp[(1<<24)+100];

int n;
double x[40], y[40], r[40];

int rec(int bit) {
    if (dp[bit] != -1) return dp[bit];
    
    if (bit == 0) return 0;
    if (__builtin_popcount(bit) == 1) return 0;
    
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if ((bit & cover[i]) || !(bit & (1<<i))) continue;
        for (int j = i+1; j < n; ++j) {
            if ((bit & cover[j]) || !(bit & (1<<j))) continue;
            
            if (c[i] == c[j]) {
                int nbit = bit ^ (1<<i) ^ (1<<j);
                int tmp = rec(nbit);
                res = max(res, tmp + 2);
            }
        }
    }
    
    //cout << bitset<7>(bit) << " : " << res << endl;
                
    return dp[bit] = res;
}

int main() {
    while (cin >> n) {
        if (n == 0) break;
    
        for (int i = 0; i < n; ++i) {
            cin >> x[i] >> y[i] >> r[i] >> c[i];
            
            cover[i] = 0;
            for (int j = 0; j < i; ++j) {
                if ( abs(x[i]-x[j], y[i]-y[j]) < r[i]+r[j]-1e-9 ) {
                    cover[i] |= (1<<j);
                }
            }
            //cout << i << " : " << cover[i] << endl;
        }
        
        memset(dp, -1, sizeof(dp));
        cout << rec( (1<<n)-1 ) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 34008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T,D,S;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
 
signed main(){
    //file(a);
    D=read(),T=read(),S=read();
    if(T*S>=D)puts("Yes");
    else puts("No");
 
 
    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (x, k, d) = [int(e) for e in lines[0].split(' ')]


    return (x, k, d)


def solve(x, k, d):

    y = abs(x)
    m =  y // d 

    if debug:
        log("x=%d, k=%d, d=%d, y=abs(x)=%d, m=%d" % (x, k, d, y, m))
    
    result = None
    if k <= m:
        result = y - k * d
    else:
        n = k - m
        if n % 2 == 0:
            result = y - m * d
        else:
            result = abs(y - m * d - d)
             

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	


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

int main(){
int i, j, H, W, K; cin >> H >> W >> K; string S[H];
for(i=0; i<H; i++){ cin >> S[i]; }
int ans=H+W-2, h=pow(2, H-1);
for(i=0; i<h; i++){ 
  int k=0, l=i, V[H]={};
  for(j=0; j<H; j++){ V[k]++; if(l%2){ k++; } l=l/2; }
  int a, b, v, U[k+1][W]={};
  for(j=0; j<W; j++){ for(a=0, v=0; a<=k; a++){ 
    for(b=0; b<V[a]; b++){ if(S[v+b][j]=='1'){ U[a][j]++; } }
    v+=V[a];
  } }
  bool d=false;
  for(j=0; j<W; j++){ for(a=0; a<=k; a++){ if(U[a][j]>K){ d=true; j=W; break; } } }
  if(d){ continue; }
  int y=0, m[k+1]={}; d=false;
  for(j=0; j<W; j++){ 
    for(a=0; a<=k; a++){ if(m[a]+U[a][j]>K){ y++; d=true; break; }else{ m[a]+=U[a][j]; } }
    if(d){ for(a=0; a<=k; a++){ m[a]=U[a][j]; } d=false; }
  } 
  ans=min(ans, y+k);
}
cout << ans << "\n";
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Stdin io = new Stdin();
            Solve(io);
        }
        static void Solve(Stdin io)
        {
            string s = io.Raw_Input();
            WriteLine(s.Count(x => x=='1'));
        }
    }
    class Stdin
    {
        public int Input()
        {
            return int.Parse(ReadLine());
        }
        public int[] Inputs()
        {
            string[] buf = ReadLine().Split(' ');
            return buf.Select(x => int.Parse(x)).ToArray();
        }
        public string Raw_Input()
        {
            return ReadLine();
        }
    }
}


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


int N, M;
int dp[(1<<8)+1][21];
vector<vector<bool>> G;

int rec(int bit, int v){
  if(dp[bit][v] != -1) return dp[bit][v];
  if(bit == (1<<v)) return dp[bit][v]=1;
  int prev_bit=bit & ~(1<<v);
  int res=0;
  for(int u=0;u<N;u++){
    if(!(prev_bit & (1<<u))) continue;
    rec(prev_bit, u);
    if(G[u][v]) res+=dp[prev_bit][u];
  }
  return dp[bit][v]=res;
}


int main(){
    cin >> N >> M;
    G.assign(N, vector<bool>(N, false));
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a][b]=G[b][a]=true;
    }
    for(int bit=0;bit<(1<<N);bit++){
        for(int v=0;v<N;v++){
            dp[bit][v]=-1;
        }
    }
    cout << rec((1<<N)-1, 0) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A,B;
	ll X[100001];
	ll ans=0;
	scan(N);scan(A);scan(B);
	rep(i,N){
		scan(X[i]);
		if(i!=0){
			if((X[i]-X[i-1])*A<=B) ans+=(X[i]-X[i-1])*A;
			else ans+=B;
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#define MOD 1000000007
typedef long long ll;

using namespace std;

ll calc(ll a, ll b, ll c) {
    if(b == 0) {
        return 1;
    }
    else if(b % 2 == 0) {
        ll d = calc(a, b / 2, c);
        return (d * d) % c;
    }
    else {
        return (a * calc(a, b - 1, c)) % c;
    }
}

ll kaijo(ll n) {
    ll ans = 1;
    for(int i = n; i > 0; i--) {
        ans *= i;
        ans %= MOD;
    }
    
    return ans;
}

int main() {
    int n, k;
    cin >> n >> k;
    
    ll x = kaijo(k - 1);
    ll y = kaijo(n - k + 1);
    
    ll v[2001] = {1};
    ll tmp = 1;
    for(int i = 1; i <= 2000; i++) {
        tmp = (tmp * calc(i, MOD - 2, MOD)) % MOD;
        v[i] = tmp;
    }
    
    for(int i = 1; i <= k; i++) {
        if(i - 1 <= n - k) {
            cout << ((((((((((x * y) % MOD) * v[i - 1]) % MOD) * v[i]) % MOD) * v[k - i]) % MOD) * v[n - k - i + 1]) % MOD) << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

struct P {
	int x, y;
};

int main() {
	int W, H;
	while ( cin >> W >> H, W || H ) {
		int sx, sy; cin >> sx >> sy; --sx, --sy;
		int gx, gy; cin >> gx >> gy; --gx, --gy;
		int n; cin >> n;
		int m[5][100][100] = {0};
		for (int i = 0; i < n; ++i) {
			int c, d, X, Y; cin >> c >> d >> X >> Y; --X, --Y, --c;
			int w, h;
			if (d == 0) w = 4, h = 2;
			else w = 2, h = 4;
			for (int y = 0; y < h; ++y) {
				for (int x = 0; x < w; ++x) {
					m[c][Y+y][X+x] = 1;
				}
			}
		}
		int c = -1;
		for (int i = 0; i < 5; ++i) {
			if (m[i][gy][gx]) c = i;
		}
		bool ans = false;
		if (c > -1) {
			queue<P> Q; Q.push( (P){sx, sy} );
			while ( !Q.empty() ) {
				P p = Q.front(); Q.pop();
				if (p.x < 0 || p.x >= W || p.y < 0 || p.y >= H) continue;
				if (!m[c][p.y][p.x]) continue;
				m[c][p.y][p.x] = 0;

				if (p.x == gx && p.y == gy) {
					ans = true;
					break;
				}

				Q.push( (P){p.x+1, p.y} );
				Q.push( (P){p.x-1, p.y} );
				Q.push( (P){p.x, p.y+1} );
				Q.push( (P){p.x, p.y-1} );
			}
		}
		if (ans) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

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

    bool open[3][3] = {false};
    for (int i = 0; i < n; i++) {
        int b; cin >> b;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a[j][k] == b) open[j][k] = true;
            }
        }
    }

    bool flag = false;
    for (int i = 0; i < 3; i++) {
        if (open[i][0] && open[i][1] && open[i][2]) flag = true;
        if (open[0][i] && open[1][i] && open[2][i]) flag = true;
    }
    if (open[0][0] && open[1][1] && open[2][2]) flag = true;
    if (open[0][2] && open[1][1] && open[2][0]) flag = true;

    cout << ((flag) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A),q(B),r(C);
    rep(i,A) cin >> p[i];
    rep(i,B) cin >> q[i];
    rep(i,C) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    vector<int> all;
    rep(i, X) all.push_back(p[i]);
    rep(i, Y) all.push_back(q[i]);
    all.insert(all.end(), r.begin(), r.end());
    sort(all.rbegin(), all.rend());
    ll ans = 0;
    rep(i, X+Y) ans += all[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <vector>
#define ll long long int

using namespace std;

int n, m;
vector<int> vec[100001];
int c[100001];

bool dfs(int x, int y){
		c[x] = y;
		for(vector<int>::iterator itr = vec[x].begin(); itr != vec[x].end(); ++itr){
				if(c[*itr] == 0 && !dfs(*itr, -y))return false;
				else if(c[*itr] == y)return false;
		}
		return true;
}

int main(int argc, char const* argv[])
{
	cin >> n >> m;
	for(int i = 0; i < m; i++){
			int a, b;
			cin >> a >> b;
			a--;
			b--;
			vec[a].push_back(b);
			vec[b].push_back(a);
	}
	if(dfs(0, 1)){
			int res = 0;
			for(int i = 0; i < n; i++){
					if(c[i] == 1)res++;
			}
			cout << (ll)res * (n - res) - m << endl;
	}else{
			cout << (ll)n * (n - 1) / 2 - m << endl;
	}
	return 0;
}


Measured memory_bytes: 6528
#include "iostream"
#include <vector>
#include <algorithm>
#include <math.h>
#include <limits.h>
using namespace std;

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

    string ans = "No";
    if (N == M) {
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long H, W;
  cin >> H >> W;
  bool foo[1010][1010] = {false};
  queue<pair<pair<long, long>, long>> q;
  rep(h, H) {
    string tmp;
    cin >> tmp;
    rep(w, W) {
      foo[h][w] = tmp[w] == '#';
      if (foo[h][w]) q.push(make_pair(make_pair(h, w), 0));
    }
  }
  long result = 0;
  while (q.size() > 0) {
    auto tmp = q.front();
    q.pop();
    long h = tmp.first.first;
    long w = tmp.first.second;
    long count = tmp.second;
    //cerr << "h: " << h << ", w: " << w << ", count: " << count << endl;
    result = count;
    if (h > 0 and foo[h-1][w] == false) {
      foo[h-1][w] = true;
      q.push(make_pair(make_pair(h-1,w), count + 1));
    }
    if (h < H-1 and foo[h+1][w] == false) {
      foo[h+1][w] = true;
      q.push(make_pair(make_pair(h+1,w), count + 1));
    }
    if (w > 0 and foo[h][w-1] == false) {
      foo[h][w-1] = true;
      q.push(make_pair(make_pair(h,w-1), count + 1));
    }
    if (w < W-1 and foo[h][w+1] == false) {
      foo[h][w+1] = true;
      q.push(make_pair(make_pair(h,w+1), count + 1));
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 25524
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    StringBuilder sb = new StringBuilder(sc.next());
    if(sb.length() <= K){
      System.out.print(sb.toString());
    }else{
      System.out.print(sb.substring(0, K).toString() + "...");
    }
  }
}


Measured memory_bytes: 38596
# -*- coding: utf-8 -*-


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    # 標準入力の取得
    N, K = list(map(int, input().split()))
    p = list(map(int, input().split()))

    return N, K, p


def main(K: int, p: list) -> None:
    """
    求解処理.

    Args:
        K (int): 購入する果物の種類
        p (list): 各果物の価格
    """
    # 求解処理
    sorted_p = sorted(p)
    ans = sum(sorted_p[:K])

    # 結果出力
    print(ans)


if __name__ == "__main__":
    N, K, p = get_input()
    main(K, p)


Measured memory_bytes: 9216
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int D(int a,int b){
    if(a%b==0)return a/b;
    return a/b+1;
}
int n,k,a[100010];
int main(){
    cin>>n>>k;
    lol(i,n)cin>>a[i];
    cout<<D(n-1,k-1)<<endl;
    return 0;
}


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

using ll = long long;

ll mod = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];
    vector<vector<ll>> dp(N + 1, vector<ll>(M + 1, 1));
    rep(i, N) rep(j, M) {
        dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j];
        if (S[i] != T[j]) dp[i + 1][j + 1] -= dp[i][j];
        dp[i + 1][j + 1] += mod;
        dp[i + 1][j + 1] %= mod;
    }
    cout << dp[N][M] << endl;
}

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



int main() {
    string s, t;
    cin >> s >> t;
    
    cout << t + s << endl;
    
    
    
    return 0;
}




Measured memory_bytes: 3612
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>

int main()
{
    int n, a[100];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    std::sort(a, a+n, [](int x, int y) -> int {
        return (x > y);
    });

    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0)sum += a[i];
        else sum -= a[i];
    }

    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int n,a[222222],dp[222222],mx;
map<int,int> mp;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
	{
		dp[i]=1;
		if (mp.find(a[i]-1)!=mp.end()) dp[i]=max(dp[i],mp[a[i]-1]+1);
		mp[a[i]]=dp[i];
	}
	for (int i=1;i<=n;i++)
	{
		mx=max(mp[i],mx);
	}
	printf("%d\n",n-mx);
	return 0;
}

Measured memory_bytes: 13184
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


template<class T> class BIT   // 1-indexed (0 is not used)
{
private:
    int num;
    vector<T> bit;
public:
    BIT(int n):bit(vector<T>(n+1, 0)), num(n) {}

    T sum(int i) {   // sum of 1..i
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, T x) {
        if (i > num) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }

    int lower_bound(T x) {
        T res=0;
        int N=1;
        while(N<num) N*=2;
        int i;
        for(i=N/2; i>0; i/=2) {
            if(res+i<num && bit[res+i]<x) {
                x = x - bit[res +i];
                res = res + i;
            }
        }
        return res + 1;
    }
};

ll InvNum( int n, int* a )
{
    map<int,int> mp;
    int i;
    for(i=0; i<n; i++) {
        mp[a[i]]=0;
    }
    int num=0;
    auto it=mp.begin();
    for(; it!=mp.end(); ++it) {
        num++;
        it->second=num;
    }

    ll ans=0;
    BIT<int> bit(num);
    for(i=0; i<n; i++) {
        ans += i - bit.sum(mp[a[i]]);
        bit.add(mp[a[i]], 1);
    }
    return ans;
}

char str[200005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    vector<int> v[26];
    int i;
    for(i=0; i<n; i++) {
        v[str[i]-'a'].push_back(i);
    }
    vector<int> flag(n);
    vector<int> p(n);
    int cnt=0;
    for(i=0; i<26; i++) {
        int odd=0;
        if((int)v[i].size()%2) {
            odd=1;
            cnt++;
        }
        int siz=(int)v[i].size();
        int k;
        for(k=0; k<siz; k++) {
            if(odd && k==siz/2) {
                flag[v[i][k]]=2;
            }
            else if(k<siz/2) {
                flag[v[i][k]]=0;
            }
            else {
                flag[v[i][k]]=1;
            }
        }
    }
    if(cnt>1) {
        printf("-1\n"); return 0;
    }

    int curr=0;
    for(i=0; i<n; i++) {
        if(flag[i]==0) {
            p[i]=curr;
            curr++;
        }
    }
    for(i=0; i<26; i++) {
        int siz=(int)v[i].size();
        int odd=0;
        if(siz%2) {
            p[v[i][siz/2]]=n/2;
        }
        int k;
        for(k=(siz+1)/2; k<siz; k++) {
            p[v[i][k]]=n-1-p[v[i][siz-1-k]];
        }
    }

    ll ans=InvNum(n, &p[0]);
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 12928
W,H,x,y,r = map(int, input().split())
res = "Yes"
if not(0 <= x-r <= W):
    res = "No"
if not(0 <= x+r <= W):
    res = "No"
if not(0 <= y-r <= H):
    res = "No"
if not(0 <= y+r <= H):
    res = "No"
print(res)


Measured memory_bytes: 5596