akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  string S;
  vector<int> cnts(3);
  int ma,mi;

  REPI(3)
    cnts[i] = 0;

  cin >> S;

  REPI(S.size ())
  {
    if (S[i] == 'a')
      cnts[0]++;
    else if (S[i] == 'b')
      cnts[1]++;
    else if (S[i] == 'c')
      cnts[2]++;
  }
  
  if (max(cnts[0],max(cnts[1],cnts[2])) - min(cnts[0],min(cnts[1],cnts[2])) >= 2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;

  return 0;
}

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

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

void logic()
{
    long long n;
    cin>>n;
    if(n==0) cout<<"No";
    else 
    {
        long long temp=n;
        int sum=0;
        while(temp>0)
        {
            sum=sum+temp%10;
            temp=temp/10;
        }
        if(n%sum==0) cout<<"Yes";
        else cout<<"No"; 
    }
    cout<<"\n";
    //incase of wrong answer...stress test your code...do not stress test yourself
    //overflow,bounds,size,constraints
    //sample tests,corner case/special case(n==0 or n==1 or negative numbers...),some hand written tests
    //read statement carefully
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(void){
  int n;
  int a[100000];
  int dif[99999] = {0};
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d", &a[i]);
    dif[a[i]] ++;
  }

  int i_0;
  if(n%2 == 0){
    i_0 = 1;
  }else{
    i_0 = 0;
  }
  for(int i=i_0; i<n; i+=2){
    if(i == 0){
      if(dif[0] != 1){
        printf("%d\n", 0);
        return 0;
      }
    }else if(dif[i] != 2){
      printf("%d\n", 0);
      return 0;
    }
  }

  int ans = 1;
  for(int i=0; i<n/2; i++){
    ans *= 2;
    ans %= 1000000007;
  }

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

  return 0;
}


Measured memory_bytes: 2460
#include<iostream>
using namespace std;
int main() {
    int q;
    cin >> q;
    int p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y;
    for (int i = 0; i < q; i++) {
        cin >> p0x >> p0y >> p1x >> p1y >> p2x >> p2y >> p3x >> p3y;
        int s1x = p0x - p1x, s1y = p0y - p1y;
        int s2x = p2x - p3x, s2y = p2y - p3y;
        if (s1x * s2x + s1y * s2y == 0) {
            cout << 1 << endl;
        } else if (s1x * s2y - s1y * s2x == 0)  {
            cout << 2 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3092
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		int max=0, count = 0;
		int[] a = new int[3];
		int[] b = new int[3];
		string[] s = Console.ReadLine().Split(' ');
		a[0] = int.Parse(s[0]);
		a[1] = int.Parse(s[1]);
		a[2] = int.Parse(s[2]);
		max = a.Max();
		
		for(int i=0;i<3;i++)
		{
			b[i] = max - a[i];
			count += b[i] / 2;
			b[i] = b[i] % 2;
			//Console.WriteLine(count+" "+b[i]);
		}
		switch(b.Sum())
		{
			case 1:
				Console.WriteLine(count+2);
				break;
			case 2:
				Console.WriteLine(count+1);
				break;
			default:
				Console.WriteLine(count);
				break;
		}
	}
}

Measured memory_bytes: 11220
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

///////////////////////////////////////////////////////////

int n,s[110];
signed main(){
  cin>>n;int sum = 0;
  rep(i,n)cin>>s[i], sum += s[i];
  sort(s,s+n);
  bool t = sum % 10 != 0;
  rep(i,n){
    if(!t && s[i] % 10 != 0){
      t = true;sum -= s[i];
      break;
    }
  }
  cout << (t ? sum : 0) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for(int i = a; i >=b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using ii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using pil = pair<int,ll>;
using vvi = vector<vi>;
using vpi = vector<ii>;

const int N = 100100;
ll mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vi a(n);
    int cnt =0;
    rep(i,0,n-1){
        cin>>a[i];
        if(i%2==0 and a[i]%2==1)cnt++;
    }
    cout<<cnt<<nl;
    return 0;
}


Measured memory_bytes: 3656
public class Main {

    /**
     * ????????????????????????
     *
     * @param args
     */
    public static void main(String[] args) {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                System.out.println(i + "x" + j + "=" + i * j);
            }
        }
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
bool know[111][111];
int l[111];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		memset(know,0,sizeof(know));
		rep(i,n){
			int m;
			cin>>m;
			rep(j,m){
				int a;
				cin>>a;
				a--;
				know[i][a]=true;
			}
		}
		int cnt=0,res=0;
		int k;
		cin>>k;
		rep(i,k){
			cin>>l[i]; l[i]--;	
		}
		rep(i,n){
			bool ok=true;
			rep(j,k){
				if(!know[i][l[j]])ok=false;
			}
			if(ok)cnt++,res=i;
		}
		if(cnt==1)cout<<res+1<<endl;
		else cout<<-1<<endl;
	}
	return 0;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

struct edge{
	int s;
	int t;
	int w;
};

const int inf = 1e18;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int n, m, p;
	vector<edge> edges;
	lld dis[2505] = { 0 };
	cin >> n >> m >> p;

	for (int i = 0; i <= n; i++) {
		dis[i] = inf;
	}
	dis[1] = 0;

	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		edges.push_back({a, b, p - c});
	}

	for (int i = 0; i < n; i++) {
		for (auto& e : edges) {
			if (dis[e.s] != inf)
				dis[e.t] = min(dis[e.t], dis[e.s] + e.w);
		}
	}

	for (int i = 0; i < n; i++) {
		for (auto &e : edges) {
			if (dis[e.s] != inf && dis[e.t] > dis[e.s] + e.w) {
				dis[e.t] = -inf;
			}
		}
	}

	if (dis[n] == -inf)
		cout << -1 << '\n';
	else 
		cout << max(0LL, -dis[n]) << '\n';

	return 0;
}

Measured memory_bytes: 384
<?php
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $d);
fscanf(STDIN, "%d", $e);
fscanf(STDIN, "%d", $k);

if($e - $a > $k) {
	print(":(\n");
} else {
	print("Yay!\n");
}

?>


Measured memory_bytes: 3700
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    
    if n < 4:
        print("No")
        sys.exit()
        
    if n%4 == 0 or n%7 == 0:
        print("Yes")
        sys.exit()

    while(n > 0):
        n -= 7
        if n%4 == 0:
            break

    if n >= 0:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 9612
#include <cstdio>
int n, x, t;
int main() {
	scanf("%d %d %d", &n, &x, &t);
	if(n % x == 0){
		printf("%d", n / x * t);
	}
	else{
		printf("%d", (n / x + 1) * t);
	}
	return 0;
} 

Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<stdio.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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;
const int day = 24*3600;

int main(){
    //cin.tie(nullptr);
	//ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    vector<int> ans;
    while(true){
        int n; cin>>n;
        if(n == 0)break;
        else{
            vector<int> imos(day,0);
            vector<int> ruiseki(day,0);
            REP(i,n){
                int a,b,c,d,e,f;
                scanf("%d:%d:%d %d:%d:%d", &a,&b,&c,&d,&e,&f);
                (void)getchar();
                //cout << a << b <<c<<d<<e<<f<<endl;
                int start = 3600*a + 60*b + c;
                int end = 3600*d + 60*e + f;
                imos[start] += 1;
                imos[end] -= 1;
            }
            ruiseki[0] = imos[0];
            int maxi = 0;
            REP(i,day-1){
                ruiseki[i+1] = ruiseki[i] + imos[i+1];
                maxi = max(maxi,ruiseki[i+1]);
            }

            ans.push_back(maxi);

        }
    }

    REP(i,ans.size()){
        cout<<ans[i] <<endl;
    }
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T ll
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

int main(){
    IOS

    int k,x;
    cin>>k>>x;
    FOR(i,max(-100000,x-k+1),min(100000,x+k-1)){
    	cout<<i<<" ";
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	return (a+b)%m;}
int sub(int a,int b,int m=mod){	return (a-b+m)%m;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
// x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	int n,m;
	cin>>n>>m;
	int par[n+1],i,a,b;
	memset(par,-1,sizeof(par));
	vector<int> g[n+1];
	for(i=0;i<m;i++)
	{
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	par[1]=1;
	queue<int> q;
	q.push(1);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(auto v:g[u])
		{
			if(par[v]!=-1)	continue;
			par[v]=u;
			q.push(v);
		}
	}
	for(i=1;i<=n;i++)
	{
		if(par[i]==-1)
		{
			cout<<"No"<<endl;
			return;
		}
	}
	cout<<"Yes"<<endl;
	for(i=2;i<=n;i++)
		cout<<par[i]<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	while(t--)	solve();
	return 0;
}

Measured memory_bytes: 12940
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    
    if x == y:
      return
    
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  
  #xが属するグループに含まれる要素数(サイズ)を返す
  def size(self, x):
    return -self.parents[self.find(x)]
  
  def same(self, x, y):
    return self.find(x) == self.find(y)
  
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  
  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
  
  def group_count(self):
    return len(self.roots)
  
  #根と根の下に属する要素のリスト辞書を返す
  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
  n, m, k = map(int, input().split())
  deg = [0]*n
  ans = [0]*n
  uf = UnionFind(n)
  for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.union(a, b)
  
  for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if uf.same(c,d):
      deg[c] += 1
      deg[d] += 1
  
  for i in range(n):
    ans[i] = uf.size(i) - 1 -deg[i]
  
  print(' '.join(map(str, ans)))
  
if __name__ == '__main__':
  main()


Measured memory_bytes: 18764
n = int(input())
a = list(map(int, input().split()))
b = [False] * n
for i in range(n - 1, -1, -1):
    if sum(b[i::i+1]) % 2 != a[i]:
        b[i] = True
res = [str(x + 1) for x, v in enumerate(b) if v]
print(len(res))
if len(res) > 0:
    print(' '.join(res))


Measured memory_bytes: 17208
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

struct Node{
  vector<int> sib;
  int cnt;
};

void unite(int t,Node node[]){
  for(int i=0;i<node[t].sib.size();i++){
    node[node[t].sib[i]].cnt+=node[t].cnt;
    unite(node[t].sib[i],node);
  }
}

int main(void){
  Node node[200010];
  int i,n,q,a,b,p,x;
  cin>>n>>q;
  node[n].cnt=0;
  for(i=1;i<n;i++){
    cin>>a>>b;
    node[a].sib.push_back(b);
    node[i].cnt=0;
  }
  for(i=0;i<q;i++){
    cin>>p>>x;
    node[p].cnt+=x;
  }
  
  unite(1,node);

  for(i=1;i<=n;i++){
    cout<<node[i].cnt<<" ";
  }

  return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int A[N], B[N];
    int ans = 0;
    rep(i, N) cin >> A[i]; rep(i, N) cin >> B[i];
    rep(i, N) ans += max(0, A[i]-B[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, a[100000], sum=0, max=0, i, j;
    scanf("%d", &n);

    for(i=0; i<n; i++)
        scanf("%d", &a[i]);

    for(i=0; i<n-1; i++)
    {
        if(a[i] >= a[i+1])
            sum++;
        else
        {
            if(sum > max)
                max = sum;

            sum = 0;
        }
    }
    if(sum > max)
        max = sum;

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


Measured memory_bytes: 512
n = gets.to_i
a = gets.split().map(&:to_i).sort.reverse
alice = []
bob =[]
i = 0
n.times do
  if i == 0
    alice << a[i]
  elsif i % 2 != 0
    bob << a[i]
  else
    alice << a[i]
  end
  i += 1
end

puts alice.inject(:+) - bob.inject(:+)

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

const int MOD=(int)1e9+7;

int main(){
  int H,W,K;
  cin >> H >> W >> K;

  vector<vector<long long>> dp(H+1,vector<long long>(W,0));
  dp.at(0).at(0)=1;
  for(int i=0;i<H;i++){
    for(int bit=0;bit<(1<<(W-1));bit++){
      bool flag=true;
      for(int j=0;j<W-2;j++){
        if((bit&(1<<j)) && (bit&(1<<(j+1))))  flag=false;
      }
      if(flag==false) continue;

      for(int j=0;j<W-2;j++){
        if((!(bit&(1<<j))) && (!(bit&(1<<(j+1))))){
          dp.at(i+1).at(j+1)+=dp.at(i).at(j+1);
          dp.at(i+1).at(j+1)%=MOD;
        }
      }
      if(!(bit&(1<<0))){
        dp.at(i+1).at(0)+=dp.at(i).at(0);
        dp.at(i+1).at(0)%=MOD;
      }
      if(W>=2 && (!(bit&(1<<(W-2))))){
        dp.at(i+1).at(W-1)+=dp.at(i).at(W-1);
        dp.at(i+1).at(W-1)%=MOD;
      }
      for(int j=0;j<W-1;j++){
        if(bit&(1<<j)){
          dp.at(i+1).at(j)+=dp.at(i).at(j+1);
          dp.at(i+1).at(j)%=MOD;
          dp.at(i+1).at(j+1)+=dp.at(i).at(j);
          dp.at(i+1).at(j+1)%=MOD;
        }
      }
    }
  }
  cout << dp.at(H).at(K-1) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun <A> countList(a: List<A>): Map<A, Long> {
        val result = mutableMapOf<A, Long>()
        a.forEach {
            result[it] = (result[it] ?: 0L) + 1L
        }
        return result
    }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val P = sc.next().toInt()
        val S = sc.next().map { it - '0' }.toTypedArray()

        var ans = 0L
        if (10 % P == 0) {
            for (i in S.indices) {
                if (S[i] % P == 0) {
                    ans += i + 1
                }
            }
        } else {
            var d = 1
            val R = S.indices.map { i ->
                val r = S[N - 1 - i] * d % P
                d *= 10
                d %= P
                r
            }
            val R2 = mutableListOf(0)
            var i = 0
            R.forEach {
                i += it
                i %= P
                R2.add(i)
            }
            countList(R2).forEach {
                val n = it.value
                ans += (n * (n - 1) / 2)
            }
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 50808
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

N = int(input())
A = np.asarray([[int(Aij) for Aij in input().split()] for _ in range(N)])

A2 = floyd_warshall(A, directed=False)

if np.any(A != A2):
    print(-1)
else:
    d = 0
    A += np.diag([2*10**9] * N)
    for i in range(N):
        for j in range(i + 1, N):
            if np.min(A[i] + A[j]) != A[i, j]:
                d += A[i, j]
    print(d)

Measured memory_bytes: 21448
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

struct UF{
    static const int MAX_N = 100000;
    int p[MAX_N];
    int r[MAX_N];

    void init(int n){
        REP(i,n){
            p[i]=i;
            r[i]=0;
        }
    }
    int find(int x){
        if(p[x]==x)return x;
        return p[x] = find(p[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return;
        if(r[x] < r[y])swap(x,y);
        if(r[x]==r[y])r[x]++;
        p[y]=x;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

int n;
vector<pair<int,P>> es;

int MST(){
    int res = 0;
    sort(es.begin(), es.end());
    UF g;
    g.init(n);
    REP(i,es.size()){
        int cost = es[i].first, u = es[i].second.first, v = es[i].second.second;
        if(g.same(u,v))continue;
        g.unite(u,v);
        res += cost;
    }
    return res;
}

int main() {
    cin >> n;
    REP(i,n){
        REP(j,n){
            int a;
            cin >> a;
            if(a==-1)continue;
            es.push_back({a,{i,j}});
        }
    }
    cout << MST() << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define MaxN 100003
#define hhhhhhh 1000000

int N;
int fa[MaxN];
long long ans, cnty[MaxN], cntx[MaxN];
map<int, bool> bk[MaxN];
struct Nd {
	int x, y;
}a[MaxN];

inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}
inline int Find(int d) {
	if(fa[d] == d) return d;
	else return fa[d] = Find(fa[d]);
} 
inline bool cmp(Nd aa, Nd bb) {
	return aa.x < bb.x;
}

int main() {
	N = Rd();
	for(reg int i = 1; i <= 100000; ++i)
		fa[i] = i;
	for(reg int i = 1; i <= N; ++i)
		a[i].x = Rd(), a[i].y = Rd();
	sort(a + 1, a + 1 + N, cmp);
	for(reg int i = 1; i < N; ++i)
		if(a[i].x == a[i + 1].x)
			fa[Find(a[i].y)] = Find(a[i + 1].y);
	for(reg int i = 1; i <= 100000; ++i)
		++cnty[Find(i)];
	for(reg int i = 1; i <= N; ++i)
		if(!bk[Find(a[i].y)][a[i].x]) {
			++cntx[Find(a[i].y)];
			bk[Find(a[i].y)][a[i].x] = true;
		}
	for(reg int i = 1; i <= 100000; ++i)
		ans += cnty[i] * cntx[i];
	cout << ans - N << endl;
	return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long a[n];
    bool f=true;
    f(i,0,n){
        cin>>a[i];
    }
    for(int i=n-1;i>0;i--){
        if(a[i]<a[i-1]){
            a[i-1]--;
        }
    }
    f(i,0,n-1){
        if(a[i]>a[i+1]){
            f=false;
        }
    }
    if(f){
         cout<<"Yes"<<endl;
     }
     else{
         cout<<"No"<<endl;
     }
    return 0;
}


Measured memory_bytes: 4368
#include<iostream>

using namespace std;

char ban[21][21];
int cont = 0;

	int w, h;
	
	int MAX = 0;

void saiki(int y, int x)
{
	cont++;
	ban[y][x] = '_';
	/*
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << ban[i][j];
		}
		cout << endl;
	}
	
	cout << w << h << endl;
	
	getchar();
	
	cout << cont << endl;;
	*/
	
	if(ban[y+1][x] == '.' && y+1 < h){
		saiki(y+1,x);
	}
	if(ban[y-1][x] == '.' && y-1 > -1){
		saiki(y-1,x);
	} 
	if(ban[y][x-1] == '.' && x-1 > -1){
		saiki(y,x-1);
	}
	if(ban[y][x+1] == '.' && x+1 < w){
		saiki(y,x+1);
	}
	
	if(cont > MAX){
		MAX = cont;
	}
}

int main()
{
	for(;;){
		int st_x, st_y;
		MAX = cont = 0;
		
		cin >> w >> h;
		
		if( w == 0){
			break;
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				ban[i][j] = '0';
			}
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> ban[i][j];
				if(ban[i][j] == '@'){
					st_x = j;
					st_y = i;
				}
			}
		}
		
		
		saiki(st_y,st_x);
		
		cout << MAX << endl;
	}
}

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

void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){
int ans[N]={0};
for(int i=0; i<M; i++){
    if(H[A[i]-1]>H[B[i]-1])ans[B[i]-1]=1;
    if(H[A[i]-1]<H[B[i]-1])ans[A[i]-1]=1;
    if(H[A[i]-1]==H[B[i]-1]){
        ans[B[i]-1]=1;
        ans[A[i]-1]=1;
    }
}
int answ=0;
for(int i=0; i<N; i++){
    if(ans[i]==0)answ++;
}
cout<< answ <<endl;
}

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


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

int main()
{
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy";
    else if (S == "Cloudy") cout << "Rainy";
    else if (S == "Rainy") cout << "Sunny";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n = int(input())
ans = 0
for i in range(1,n+1):
  if i % 2 == 1 and len(make_divisors(i)) == 8:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int ans = 0;
  char now = ' ';
  rep(i, n){
    if (now != s[i]){
      ans++;
      now = s[i];
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3752
import sys
h, w, k = map(int, input().split()) 
s = sys.stdin.readlines()
ans = 0
for ib in range(1<<h):
  for jb in range(1<<w):
    cnt = 0
    for i in range(h):
      if ib >> i & 1:
        continue
      for j in range(w):
        if jb >> j & 1:
          continue
        if s[i][j] == "#":
          cnt += 1
    if cnt == k:
      ans += 1
print (ans)

Measured memory_bytes: 9140
n, m = map(int, input().split())
num = [0] * m
for i in range(n):
    aa = list(map(int, input().split()))
    for a in aa[1:]:
        num[a - 1] += 1
ans = 0
for j in range(m):
    if num[j] == n:
        ans += 1
print(ans)


Measured memory_bytes: 2940
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[30][1 << 23], a[100][100], b[200000];
string str, ss;
bool f;
char c[800][800];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<Edge>vec[20000];
vector<edge>ed;
vector<LL>v[23];
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}
	rep(i, 1 << n) {
		bitset<30>bi = i;
		v[bi.count()].push_back(i);
	}
	dp[0][0] = 1;
	rep(i, n) {
		rep(k,v[i].size()) {
			LL mask = v[i][k];
			rep(j, n) {
				if (a[i][j] && !(mask&(1 << j))) {
					dp[i + 1][mask | (1 << j)] += dp[i][mask];
					dp[i + 1][mask | (1 << j)] %= MOD;
				}
			}

		}
	}
	cout << dp[n][(1 << n) - 1] << endl;
	return 0;
}


Measured memory_bytes: 360992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

const int INF = 1001001001;

int main() {
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.size();
	if (n <= k) {
		cout << s;
	}
	else {
		rep(i, k) {
			cout << s[i];
		}
		cout << "...";
	}
	return 0;
}













Measured memory_bytes: 3600
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>
#define MAX 100000
typedef long long ll;
using namespace std;

int n;
static const double pi = 3.141592653589793;

void kock(int n, pair<double, double> p1, pair<double, double> p2)
{
    if (n == 0)
    {
        return;
    }
    double sx = (2 * p1.first + p2.first) / 3;
    double sy = (2 * p1.second + p2.second) / 3;
    double tx = (p1.first + 2 * p2.first) / 3;
    double ty = (p1.second + 2 * p2.second) / 3;
    double ux = (tx - sx) * cos(pi / 3) - (ty - sy) * sin(pi / 3) + sx;
    double uy = (tx - sx) * sin(pi / 3) + (ty - sy) * cos(pi / 3) + sy;

    pair<double, double> s = make_pair(sx, sy);
    pair<double, double> t = make_pair(tx, ty);
    pair<double, double> u = make_pair(ux, uy);

    kock(n - 1, p1, s);
    printf("%.8f %.8f\n", s.first, s.second);
    kock(n - 1, s, u);
    printf("%.8f %.8f\n", u.first, u.second);
    kock(n - 1, u, t);
    printf("%.8f %.8f\n", t.first, t.second);
    kock(n - 1, t, p2);
}

int main()
{
    cin >> n;
    pair<double, double> p1 = make_pair(0, 0);
    pair<double, double> p2 = make_pair(100, 0);
    printf("%.8f %.8f\n", p1.first, p1.second);
    kock(n, p1, p2);
    printf("%.8f %.8f\n", p2.first, p2.second);
    return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include <cstdlib>
#define size(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  if(abs(a - b) > abs(a - c)){
    cout << "B";
  }else{
    cout << "A";
  }
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    int cnt = 0;
    char previous;
    rep(i, n) {
        char c = s[i];
        if(previous != c) {
            cnt++;
        }
        previous = c;
    }
    
    cout << cnt;
}


Measured memory_bytes: 512
V=0;
o=input().rstrip().split(' ')
p=input().rstrip().split(' ')
S=0;
for i in range(0,len(p)):
    S+=int(p[i])
D=(1/(4*int(o[1])))*100;
p.sort(key=int,reverse=True)
for i in range(0,int(o[1])):
    G = (int(p[i])/S)*100;
    if G >= D:
        continue;
    else:
        V=1;
        break;
#print(D,G)
if V==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdbool.h>

#define maxn 200001

bool can[maxn];
int count[maxn];

int main( void ) {
	int n, m;
	scanf("%i %i", &n, &m);
	
	can[1] = true;
	for( int i = 1; i <= n; i++ ) {
		count[i] = 1;
	}
	
	while( m-- ) {
		int x, y;
		scanf("%i %i", &x, &y);
		
		if( can[x] ) {
			can[y] = true;
		}
		
		count[y]++;
		count[x]--;
		
		if( count[x] == 0 ) {
			can[x] = false;
		}
	}
	
	int ans = 0;
	for( int i = 1; i <= n; i++ ) {
		if( can[i] ) ans++;
	}
	
	printf("%i\n", ans);
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(void){
	int a,b;
	cin >> a >> b;
	if(a*b>a+b && a*b>a-b){
		cout << a*b << endl;
	}else if(a+b>a-b){
		cout << a+b << endl;
	}else
		cout << a-b << endl;
	
	
return 0;
}

Measured memory_bytes: 256
/*
    oj d https://atcoder.jp/contests/abc167/tasks/abc167_c
    g++ C.cpp
    oj t
    oj s https://atcoder.jp/contests/abc167/tasks/abc167_c C.cpp
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int N, M;
ll X, C[12], A[12][12];
ll mincost = -1;

void dfs(int d, vector<int>& vec){
    if(d < N){
        vec.push_back(0);
        dfs(d+1, vec);
        vec.pop_back();
        vec.push_back(1);
        dfs(d+1, vec);
        vec.pop_back();  
    }else{
        // M個のアルゴリズム
        bool flag = true;
        for(int j=0;j<M;j++){
            // N冊の本
            ll u = 0;
            for(int i=0;i<N;i++){
                if(vec[i] == 1)
                    u += A[i][j];
            }
            if(u < X){
                flag = false;
                break;
            }   
        }
        if(flag){
            ll cost = 0;
            for(int i=0;i<N;i++){
                if(vec[i] == 1)
                    cost += C[i];
            }
            if(cost < mincost)
                mincost = cost;
            else if(mincost == -1)
                mincost = cost;
        }
    }
}
 
int main(){
    cin >> N >> M >> X;
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++)
            cin >> A[i][j];
    }

    vector<int> v;
    dfs(0, v);
    
    cout << mincost << endl;
    
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
 
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>
 
using std::endl;
using std::string;
 
#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 123456789012345
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std
 
ll A, B;
 
 
int main()
{
	IN >> A >> B;
 
	if ((A * B) % 2 == 0) OUT << "No" << endl;
	else OUT << "Yes" << endl;
 
 
	return 0;
}

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

public static class combi
{
    public static IEnumerable<IEnumerable<T>> Comb<T>(this IEnumerable<T> items, int r)
    {
        if (r == 0)
        {
            yield return Enumerable.Empty<T>();
        }
        else
        {
            var i = 1;
            foreach (var x in items)
            {
                var xs = items.Skip(i);
                foreach (var c in Comb(xs, r - 1))
                    yield return c.Before(x);
                i++;
            }
        }
    }
    public static IEnumerable<T> Before<T>(this IEnumerable<T> items, T first)
    {
        yield return first;
        foreach (var i in items)
            yield return i;
    }
}

public class P
{
    public int a { get; set; }
    public int[] b { get; set; }
}

public class hello
{
    public static void Main()
    {
        var ps = new List<P>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var pow = new int[n];
        pow[0] = 1;
        for (int i = 1; i < n; i++) pow[i] = pow[i - 1] * 2;
        var a = Enumerable.Range(0, n).Comb(k);
        foreach (var x in a)
        {
            var w = new P { b = new int[k] };
            w.b = x.ToArray();
            var t = 0;
            foreach (var y in w.b) t += pow[y];
            w.a = t;
            ps.Add(w);
        }
        print(ps);
    }
    public static void print(List<P> ps)
    {
        var sb = new StringBuilder();
        foreach (var x in ps.OrderBy(y => y.a))
            if (x.b.Count() == 0) sb.Append(string.Format("{0}:\n", x.a));
            else
            {
                sb.Append(string.Format("{0}: ", x.a));
                sb.Append(string.Join(" ", x.b));
                sb.Append("\n");
            }
        Console.Write(sb);
    }
}


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

int main() {
    int n,h,w;
    cin >> n >> h >> w;
    int count = 0;
    for(int i=0;i<n;i++){
        int a,b;
        cin >>a >> b;
        if(a>=h&&b>=w) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
n,m,d = map(int, input().split())
# for each section, mean is:
# (n*2-d*2)/(n^2)
# ex. n=7, d=2
# (1,3) (2,4) (3,5) (3,1) (4,6) (4,2) (5,7) (5,3) (6,4) (7,5)
ans = (n-d)*2/(n*n)*(m-1)
if d==0: ans /= 2
print(ans)

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a)

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	string S,T;
	cin >> S >> T;
	
	
	//SOLVE
	puts(T);
	put(S);
	
	return 0;
}






Measured memory_bytes: 764
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var w = "yuiophjklnm";
        while (true)
        {
            var s = Console.ReadLine().Trim();
            if (s == "#") break;
            var count = 0;
            var r = w.Contains(s[0]);
            for (int i = 1; i < s.Length; i++)
                if (w.Contains(s[i]) != r) { count++; r = !r; }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 9896
import java.util.Scanner;


public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		
		int a = A.length();
		int b = B.length();
		
		char Bfirst = B.charAt(0); 
		char Cfirst = C.charAt(0);
		
		char Alast = A.charAt(a-1);
		char Blast = B.charAt(b-1);
		
		if((Bfirst == Alast) & (Cfirst == Blast)){
			System.out.println("YES");	
		}else{
			System.out.println("NO");
		}
		
	}

}

Measured memory_bytes: 20948
#include "bits/stdc++.h"

using namespace std;

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

vector< pair<int,string> > data;


string solve(int op,vector<int> num){
	int ret=0;
	if( data[op].second=="+" ){
		rep(i,num.size()) ret+=stoi( data[num[i]].second );
	}
	else if( data[op].second=="*" ){
		ret=1;
		rep(i,num.size()) ret*=stoi( data[num[i]].second );
	}
	stringstream ss;
	ss<<ret;
	return ss.str();
}


int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		string input[50];
		rep(i,n) cin>>input[i];
		
		data.clear();
		rep(i,n) data.push_back(  make_pair( input[i].size(),string(1, input[i][ input[i].size()-1 ] ) )  );
		
		while(1){
			int deepval=0;
			vector<int> deepnum;
			rep(i,data.size()){
				if( deepval<data[i].first ){
					deepval = data[i].first;
					deepnum.clear();
					deepnum.pb(i);
				}
				else if(deepval==data[i].first && deepnum[ deepnum.size()-1 ]+1==i){
					deepnum.pb(i);
				}
			}
			if( deepnum.size()==1 && data.size()==1){ cout<<data[0].second<<endl; break; }
			else{
				int op = deepnum[0]-1;
				data[op].second = solve( op,deepnum );
				
				int len=deepnum.size();
				rep(i,len) data.erase( data.begin()+op+1 );
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#define all(v) (v).begin(),(v).end()

using namespace std;

int main(){
  	int N, K;
  	cin >> N >> K;
  	vector<int> a(N);
  	for(int i=0;i<N;i++) cin >> a[i];
  	sort(all(a), greater<int>());
  	cout << accumulate(a.begin(), a.begin() + K, 0) << endl;
}

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

int main() {
    string s1,s2;
    int l1,l2;
    cin >> s1 >> s2;
    l1=s1.size(), l2=s2.size();
    vector<vector<int>> dp(l1+1, vector<int>(l2+1));
    rep(i,l1)
        dp.at(i+1).at(0) = i+1;
    rep(i,l2)
        dp.at(0).at(i+1) = i+1;
    
    rep(i,l1)
        rep(j,l2) {
            dp.at(i+1).at(j+1) = min(dp.at(i).at(j+1)+1, dp.at(i+1).at(j)+1);
            if(s1.at(i) == s2.at(j))
                dp.at(i+1).at(j+1) = min(dp.at(i+1).at(j+1), dp.at(i).at(j));
            else
                dp.at(i+1).at(j+1) = min(dp.at(i+1).at(j+1), dp.at(i).at(j)+1);
        }

    cout << dp.at(l1).at(l2) << endl;    
}


Measured memory_bytes: 6808
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;

        signed main() {
        int n;
        cin>>n;
        if(n%2)cout<<n/2 +1;
        else cout<<n/2;

  

      }


        


Measured memory_bytes: 764