akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, a; cin >> n >> a;
    vi x(n+1), y(n+1);

    // 入力処理をしつつ最大値を取得（dp配列用）
    ll maxA = a;
    // 1-based
    repf(i, n){
        cin >> x[i];
        y[i] = x[i]-a;
        chmax(maxA, y[i]);
    }

    // y1...ynから任意の枚数選んで合計が0になる組み合わせを数える
    // dp[i][j]; y1..yiから0枚以上選んだ合計がj-n*maxAとなるような選び方
    ll sizeSum = 2*n*maxA+1;
    vvi dp(n+1, vi(sizeSum));

    // yiは負値を取る可能性があるため、0をn*maxA（Aも含めて全て最大値だった場合）にずらす
    // 1枚も選ばないで0となるパターンが1種類
    dp[0][n*maxA] = 1;

    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=sizeSum; j++){
            if(j-y[i]<0 || j-y[i]>2*n*maxA) dp[i][j] = dp[i-1][j];
            else dp[i][j] = dp[i-1][j] + dp[i-1][j-y[i]];
        }
    }

    // 1枚も選ばないパターンを減算して出力
    cout << dp[n][n*maxA]-1 << endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++) cin >> s[i];

    map<string, int> mp;
    for(int i=0; i<n; i++){
        mp[s[i]]++;
    }
    int maxs = -1;
    for(int i=0; i<n; i++){
        maxs = max(maxs, mp[s[i]]);//ok
    }
    for(auto p : mp){
        auto k =p.first;
        auto v =p.second;

        if(v == maxs) cout << k << endl;
    }
    return 0;
}

Measured memory_bytes: 25472
#include<stdio.h>
#include<iostream>
using namespace std;

int N,K,X,Y;
int main (){
    int sum = 0;
    cin >> N >> K >> X >> Y;
    if (N > K) sum += (N - K) * Y + K * X;
    else sum += N * X;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
str = gets.strip
first, last = str.scan(/.{1,2}/)

if first.to_i < 13 && first.to_i > 0 && last.to_i < 13 && last.to_i > 0
  puts 'AMBIGUOUS'
elsif first.to_i < 13 && first.to_i > 0
  puts 'MMYY'
elsif last.to_i < 13 && last.to_i > 0
  puts 'YYMM'
else
  puts 'NA'
end

Measured memory_bytes: 1788
x = int(input())
base = [0]
now = 1
while now ** 5 - base[-1] <= 10 ** 9:
  base.append(now ** 5)
  now += 1
for a,va in enumerate(base[1:],1):
  for b,vb in enumerate(base[:a]):
    if va - vb == x:
      print(a,b)
      break
    elif va + vb == x:
      print(a,-b)
      break


Measured memory_bytes: 63780
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    int k,s;
    cin>>k>>s;
    ll ans=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int z = s-i-j;
            if(z<0)continue;
            if(z>k)continue;
            ans++;
        }
    }
    fin(ans);
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int N;
  cin >> N;
  vector<int> C(N),S(N),F(N);

  REP(i,N){
    cin >> C[i];
    cin >> S[i];
    cin >> F[i];
  }

  REP(i,N-1){
    int t=0;
    FOR(j,i,N-1){
      if(S[j]<=t){
        t=((t-S[j]+F[j]-1)/F[j])*F[j] + S[j] + C[j];
      }else{
        t=S[j]+C[j];
      }
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}



Measured memory_bytes: 256
n = int(input())
test = []
for i in range(n):
    test.append(input())
print('AC x ' + str(test.count('AC')))
print('WA x ' + str(test.count('WA')))
print('TLE x ' + str(test.count('TLE')))
print('RE x ' + str(test.count('RE')))

Measured memory_bytes: 16296
#if 0
date +%Y.%m.%d

题解先咕着。
        ▁▃▄▄▄▃▃▃▃▄▶
      ▗▇▀▔    ▔▔▔▔
     ▄▛   ▃▅━━■▄▂
    ▟▊   ▐▘     ▀▙
   ▟▜▌   ▐▖   ▋  ▐▍
  ▟▘ ▜   ▝▀▇▆●▘  ▐▌
▗▟▘   ▜▃       ▁▅▛
▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔   CopyRight :)
      ▔▔▔▔▔▔
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

int main () {
	int h1 = read, m1 = read, h2 = read, m2 = read, k = read;
	printf("%d\n", (h2 * 60 + m2) - (h1 * 60 + m1) - k);
}


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

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

    int m;
    cin >> m;
    int p[m], x[m];
    for(int i=0;i<m;i++){
        cin >> p[i] >> x[i];
    }

    int sum = 0;
    int ans = 0;
    for(int j=0;j<n;j++){
        sum += t[j];
    }
    ans = sum;
    for(int k=0;k<m;k++){
        ans = sum - t[p[k]-1] + x[k];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
g=[a,b,c]
x,y=map(int,input().split())
def gomi():
  for i in g:
    if x in i and y in i:
      print("Yes")
      return
  print("No")
  return
gomi()

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

int main() {
  long A,B,K;
  cin>>A>>B>>K;

  if(K>=A) K-=A,A=0;
  else A-=K,K=0;
  if(K>=B) B=0;
  else B-=K;
  cout<<A<<" "<<B<<endl;
  }


Measured memory_bytes: 256
#include<stdio.h>//????°???¨?????¨,?????????????????????????????°?????? G=(V,E)
                 //????????????????°???¨?????¨????????????????????????????¨??????????????????°???????????????

#define N 2000
#define A 101
#define NIL -1

void Prim();

static const int MAX=500;
static const int INFTY=(1<<21);

int M[A][A], p[A], n, s;

main(){
  int i, j, e;
  
  scanf("%d", &n);
  //??????????????? G ???????????° n ?????????????????????????¶???? n ?????§ G ?????¨??? n??n ?????£??\?????? A ????????????????????????
  //A ???????´? aij ???????????? i ??¨?????? j ????????¶?????????????????¨?????????????????????????????????????????°-1 ??§?????????????????? 
  
  for (i=0; i<n; i++ )
    for (j=0; j<n; j++ ){
      scanf("%d", &e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  
  s=0;
  Prim();//G ???????°???¨?????¨??????????????????????????????????????????????????????????????? 
  printf("%d\n", s);
  return 0;
}

void Prim(){
  int i, v, u, k[A];

  for(u=0;u<n;u++){
    k[u]=INFTY;
    p[u]=NIL;
  }

  k[0]=0;

  while(1){
    int minv=INFTY;
    u=NIL;

    for(i=0;i<n;i++)
      if(k[i] < minv && p[i]==NIL ){
	u=i;
	minv=k[i];
      }
    
    if(u==NIL) break;
    p[u]=1;
    s+=k[u];
    
    for(v=0;v<n;v++)
      if(M[u][v]<k[v]){
	k[v]=M[u][v];
      }    
  }
}

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

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  string s;cin>>s;
  string rgb="RGB";
  map<char,vector<int>> mrgb;
  ll ans=0;
  for(int i=0;i<n;i++){
    mrgb[s[i]].push_back(i);
  }
  vector<int> &r=mrgb['R'];
  vector<int> &g=mrgb['G'];
  vector<int> &b=mrgb['B'];
  ans=r.size()*g.size()*b.size();
  for(int i=0;i<r.size();i++){
    for(int j=0;j<g.size();j++){
      int l,s;
      if(r[i]<g[j]){
        l=g[j];
        s=r[i];
      }else{
        l=r[i];
        s=g[j];
      }
      int ng=s-(l-s);
      if(find(all(b),ng)!=b.end()){
        ans--;
      }
      ng=(s+l)/2;
      if(find(all(b),ng)!=b.end()){
        if((s+l)%2==0){
          ans--;
        }
      }
      ng=l+(l-s);
      if(find(all(b),ng)!=b.end()){
        ans--;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int k, n, c;
int main() {
    while(cin >> k, k != 0) {
        int ans = 0;
        for (int i = 0; i < k * (k - 1) / 2; ++i) {
            cin >> c; ans += c;
        }
        ans /= (k - 1);
        cout << ans << endl;
    }
}


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

int main() {

	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int maxa=0;

	rep(i, n - 1) maxa = max(maxa, a[i + 1] - a[i]);
	maxa = max(maxa, k - a[n - 1] + a[0]);

	cout << k - maxa << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
 
using namespace std ;
 
typedef double D ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned int ui ;
typedef unsigned long long ull ;
 
# define F first
# define S second
# define R return
# define C continue 
# define pb push_back 
# define pf push_front
# define mp make_pair
 
# define vi vector <int>
# define vb vector <bool>
# define vc vector <char>
# define vll vector <ll>
# define vs vector <string>
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
 
# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >
# define vvpii vector < vector < pii > >
 
# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define FAST ios_base :: sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0)
 
const ll MOD = 1e9 + 7 ;
const int infi =  INT_MAX ;
const ll infll =  LLONG_MAX ;
const ld PI = 3.1415926535897932384626 ;

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

ll pow(ll a , ll b , ll m) {
	ll ans = 1 ;
	while(b)
	{
		if (b&1) {
			ans = (ans*a) % m ;
		}
		b /= 2 ;
		a = (a*a) % m ;
	}
	return ans ;
}

bool isprime(ll n) {
    for (ll i = 2 ; i * i <= n ; ++i)
        if (n % i == 0) {
        	return false ;
		}
    return true;
}

ll gcd(ll a, ll b) {
    if (b == 0) {
    	return a ;
	}
    else {
    	return gcd (b , a % b) ;
	}
}

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

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

void solve (int test_case) {
	ld a , b ;
	cin >> a >> b ;
	ld p = a*b ;
	cout << ll(p) ;
}

int main() {
	FAST ;
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	int tc = 1 ;
//	cin >> tc ;
	while (tc--) {
		solve (tc) ;
	}
	return 0 ;
}

Measured memory_bytes: 3740
#include <cstddef>
#include <cstdint>
#include <vector>

using u64 = std::uint_fast64_t;

template <u64 Modulus, u64 BaseX, u64 BaseY> class rolling_hash_2d {
  std::vector<std::vector<u64>> prefix;
  std::vector<u64> power_x, power_y;

public:
  rolling_hash_2d(const std::vector<std::vector<u64>> &table)
      : prefix(), power_x(), power_y() {
    const std::size_t h = table.size();
    const std::size_t w = table.empty() ? 0 : table.front().size();
    prefix.resize(h + 1, std::vector<u64>(w + 1, 0));
    for (std::size_t i = 0; i != h; ++i) {
      for (std::size_t j = 0; j != w; ++j) {
        prefix[i + 1][j + 1] =
            (Modulus - prefix[i][j] * (BaseX * BaseY) +
             prefix[i][j + 1] * BaseX + prefix[i + 1][j] * BaseY + table[i][j]);
      }
    }
    power_x.resize(h + 1);
    power_x[0] = 1;
    for (std::size_t i = 0; i != h; ++i) {
      power_x[i + 1] = power_x[i] * BaseX;
    }
    power_y.resize(w + 1);
    power_y[0] = 1;
    for (std::size_t i = 0; i != w; ++i) {
      power_y[i + 1] = power_y[i] * BaseY;
    }
  }
  u64 operator()(const std::size_t l, const std::size_t d, const std::size_t r,
                 const std::size_t u) const {
    return (prefix[l][d] * (power_x[r - l] * power_y[u - d]) + Modulus -
            prefix[l][u] * power_x[r - l] + Modulus -
            prefix[r][d] * power_y[u - d] + prefix[r][u]);
  }
};

#include <iostream>

int main() {
  int n;
  std::cin >> n;
  std::vector<std::vector<u64>> s(n * 2, std::vector<u64>(n * 2)), t = s;
  for (int i = 0; i != n; ++i) {
    char c;
    for (int j = 0; j != n; ++j) {
      std::cin >> c;
      const u64 v = c - 'a';
      s[i][j] = v;
      s[i][n + j] = v;
      s[n + i][j] = v;
      s[n + i][n + j] = v;
      t[j][i] = v;
      t[j][n + i] = v;
      t[n + j][i] = v;
      t[n + j][n + i] = v;
    }
  }

  static constexpr u64 Modulus = 1000000007;
  static constexpr u64 BaseX = 25254841;
  static constexpr u64 BaseY = 75628891;

  const rolling_hash_2d<Modulus, BaseX, BaseY> sh(s), th(t);

  int ans = 0;

  for (int i = 0; i != n; ++i) {
    for (int j = 0; j != n; ++j) {
      if (sh(i, j, n + i, n + j) == th(j, i, n + j, n + i)) {
        ++ans;
      }
    }
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 11648
n=int(input())
a=list(map(int,input().split()))
a1=0
b=0
c=0
d=0
e=0
f=0
g=0
h=0
ans=0
for i in range(n):
  if 1<=a[i]<=399:
    a1=1
  elif 400<=a[i]<=799:
    b=1
  elif 800<=a[i]<=1199:
    c=1
  elif 1200<=a[i]<=1599:
    d=1
  elif 1600<=a[i]<=1999:
    e=1
  elif 2000<=a[i]<=2399:
    f=1
  elif 2400<=a[i]<=2799:
    g=1
  elif 2800<=a[i]<=3199:
    h=1
  else:
    ans+=1

x=a1+b+c+d+e+f+g+h
if a1==b==c==d==e==f==g==h==0:
  print(1,ans)
else:
  print(x,x+ans)

Measured memory_bytes: 9200
/**
 * Created by akensho on 2015/11/22.
 */
import java.util.*;
class Main {
    static int n;
    static int[] a;
    static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args){
        while( read() ){
            insertionSort(a);
        }
    }

    static boolean read(){
        if( !scanner.hasNext() ) return false;
        n = scanner.nextInt();
        a = new int[n];
        for(int i = 0; i < a.length; i++){
            a[i] = scanner.nextInt();
        }
        return true;
    }

    /**
     * ?????\??????????????????????????????
     * @param array := 0-indexed ??§ N ??????????´????????????????
     * return ????????????????????????
     */
    static int[] insertionSort(int[] array){
        for (int i = 0; i < array.length; i++) {
            int v = array[i];
            int j = i-1;
            while ( j >= 0 && array[j] > v ){
                array[j+1] = array[j];
                j--;
            }
            array[j+1] = v;
            traceArray(array);
        }
        return array;
    }

    static void traceArray(int[] array){
        for(int i = 0; i < array.length; i++){
            if (i == array.length - 1) {
                System.out.print(array[i]);
                continue;
            }
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }

}

Measured memory_bytes: 29676
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	int N;
	cin>>N;
	ll ans=0;
	for(ll i=1;i<=N-1;i++){
		ll tmp=0;
		for(ll j=0;j<10;j++)tmp+=i;
		ans+=tmp/10;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int ans = 0;
    REP(i, N) {
        int A, B;
        cin >> A >> B;
        a[i] = A + B;
        ans += A;
    }
    sort(RALL(a));
    REP(i, N) {
        if (i % 2) {
            ans -= a[i];
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 1024
<?php

$lines = array();
while(($v = intval(fgets(STDIN)))){ 
    array_push($lines, $v);
}


for($i=0; $i<count($lines); $i++){
    if ($lines !== 0){
        echo "Case " . ($i+1) . ": "  . $lines[$i],PHP_EOL;
    }
}

Measured memory_bytes: 16304
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

struct UnionFind {
  vector<int> par;
  
  UnionFind(int N) : par(N) {
    for (int i=0; i<N; i++) par[i] = i;
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int N, M;
int P[100010];

int main() {
  cin >> N >> M;
  rep(i, 0, N) cin >> P[i];

  UnionFind tree(N);
  rep(i, 0, M) {
    int x, y;
    cin >> x >> y;
    tree.unite(x-1, y-1);
  }

  int res = 0;
  rep(i, 0, N) {
    if (tree.same(i, P[i]-1)) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int n = 100001;

int cmp[n];
int nums[n];

vector<int> vis;
vector<int> G[n];

int N, M, C = 0, res = 0;

void DFS(int i){
	cmp[i] = C;
	for(int j : G[i]){
		if(cmp[j] == -1){
			DFS(j);
		}
	}
	vis.push_back(nums[i]);
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < N; ++i){
		cin >> nums[i];
		nums[i]--;
	}

	for(int i =  0; i < M; ++i){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	fill_n(cmp, N, -1);
	for(int i = 0; i < N; ++i){
		if(cmp[i] == -1){
			DFS(i);
			for(int v : vis){
				if(cmp[v] == C){
					res++;
				}
			}
			vis.clear();
			C++;
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 9212
#include <stdio.h>

int main(void)
{
    int i,n,m;
    double x;

    scanf("%d",&n);

    int a[n];

    m=0;

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

    for ( i = 1; i <= n; i+=2)
    {
        x = a[i]%2;
        if(x!=0){
            m++;
        }
    }


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

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

int main()
{

    int n,k;
    char s[50];

    scanf("%d%d",&n,&k);
    for(int i=0; i<=n; i++){
        scanf("%c",&s[i]);
    }

    if(n>=1 && n<=50 && k>=1 && k<=n){
        s[k] = tolower(s[k]);
        for(int i=0; i<=n; i++){
            printf("%c",s[i]);
        }
    }


    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
t,a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
k = 100000000
ans = 0

n.times do |i|
	if k > (a - (t - h[i] * 0.006)).abs
		k = (a - (t - h[i] * 0.006)).abs
		ans = i + 1
	end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
    int d,s,t;
    cin>>d>>t>>s;
    if((double)d/(double)s<=(double)t)cout<<"Yes";
    else cout<<"No";

}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int h[n],cost[n];
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	cost[0]=0;
	cost[1]=abs(h[1]-h[0]);
	for(int j=2;j<n;j++)
	{
		cost[j]=min(abs(h[j]-h[j-1])+cost[j-1],abs(h[j]-h[j-2])+cost[j-2]);
	}
	cout<<cost[n-1]<<endl;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
E = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  E[a].append(b)
  E[b].append(a)
r = 0
c = 0
s = 1
l = 1
q = [(c, s, l)]
while q:
  c, s, l = q.pop()
  if l == N:
    r += 1
    continue
  for n in E[c]:
    if s&(1<<n) == 0:
      q.append((n, s|(1<<n), l+1))
print(r)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main()
{
	int a[5];
	int k;
	for (size_t i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	cin >> k;

		if (a[4] - a[0] > k)
		{
			cout << ":(" << endl;
			return 0;
		}
	cout << "Yay!" << endl;
	return 0;
}


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

string toUpper(string s){
    string t = s;
    for(int i = 0; i < s.size(); i++){
        t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
    string str1, str2;
    int n = 0, cnt =0;
    while(true){
        cin >>str1;
        if(str1 == "-") break;
        cin >>cnt;
        
        for(int i = 0; i<cnt; i++){
            cin >>n;
            str2 = str1.substr(0, n);
            str1.erase(0, n);
            str1 += str2;
        }
        cout << str1 << endl;

    }
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>

int main()
{
	int N;
	std::cin >> N;
	int H;
	std::cin >> H;
	int W;
	std::cin >> W;

	int ans;
	int col, row;

	col = N - W + 1;
	row = N - H + 1;

	ans = col * row;

	std::cout << ans; 
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <map>

using namespace std;

int main()
{
    int N, M;
    if (scanf("%d%d", &N, &M) < 2) return 0;

    map<int, int> m;

    for (int i = 0; i < M; i++)
    {
        int a, b;
        if (scanf("%d%d", &a, &b) < 2) return 0;
        m[a]++;
        m[b]++;
    }

    for (int i = 1; i <= N; i++)
    {
        if (m.count(i) == 1) printf("%d\n", m[i]);
        else printf("%d\n", 0);
    }

    return 0;
}


Measured memory_bytes: 256
s = input()
check = False
if len(set(s)) == 1:
    check = True
n = len(s)
K = int(input())
s = s*2
s = list(s)
cnt = 0
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        s[i] = 'A'
        cnt += 1
res = 0
if cnt % 2 == 1:
    res = (cnt//2)*K + K-1
else:
    res = cnt//2 * K
if check:
    res = n * K // 2
if n == 1:
    res = K//2
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define io  ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
int gcd ( int a , int b ){
    if(a%b==0)return b;
    return gcd ( b , a%b );
}
int main(){
    int k,sum = 0;
    cin>>k;
    for(int i =1 ; i<= k ;i++){
        for(int j = 1; j<= k ;j++){
            for(int p =1;p<=k ;p++){
              sum+=  gcd(i,gcd(j,p));
            }
        }
    }
    cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<queue>
#include<vector>
#include<utility>
using namespace std;
using pii=pair<int,int>;

int dist[102];
queue<pii> q;
vector<int> adj[105];
bool vis[105];

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=1,u,k;i<=n;i++){
		cin>>u>>k;
		for(int j=0,tt;j<k;j++){
			cin>>tt;
			adj[u].push_back(tt);
		}
	}
	
	q.push({1,0});
	dist[1]=0;
	for(int i=2;i<=n;i++) dist[i]=1e8;
	
	while(!q.empty()){
		int from=q.front().first, fw=q.front().second;
		q.pop();
		if(fw!=dist[from]) continue;

		for(int to:adj[from]){
			if(dist[to]>dist[from]+1){
				dist[to]=dist[from]+1;
				q.push({to,dist[from]+1});
			}
		}
	}
	
	for(int i=1;i<=n;i++){
		cout<< i <<' '<< ((dist[i]==1e8)?-1:dist[i]) <<endl;
	}
}


Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
int n,m;
int a[200005];
int b[200005];

int main() {
    cin>>n>>m;
    rep(i,m) cin>>a[i];
    rep(i,m) a[i]--;
    rep(i,200005) b[i]=1e8;
    rep(i,m) b[a[i]]=0;
    rep(i,n) if(i) {
        b[i]=min(b[i],b[i-1]+1);
    }
    for(int i=n-1;i>=0;i--) if(i+1!=n) b[i]=min(b[i],b[i+1]+1);

    int ans=0;
    rep(i,n) ans=max(ans,b[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2084
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

#define MAX 256

int main(void){
	int h[MAX], w[MAX];
	int i = 0, t = 1;
	while (t == 1){
		scanf("%d %d", &h[i], &w[i]);
		if (h[i] == 0 && w[i] == 0)t = 0;
		i++;
	}

	for (int j = 0; j < i; j++){
		for (int k = 0; k < h[j]; k++){
			for (int l = 0; l < w[j]; l++){
				printf("#");
			}
			printf("\n");
		}
		if (j != i - 1)printf("\n");
	}

	return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int H, W, A, B; cin >> H >> W >> A >> B;
  for (int i = 0; i < B; i++) {
    for (int j = 0; j < A; j++) {
      cout << "0";
    }
    for (int j = 0; j < W-A; j++) {
      cout << "1";
    }
    cout << "\n";
  }
  for (int i = 0; i < H-B; i++) {
    for (int j = 0; j < A; j++) {
      cout << "1";
    }
    for (int j = 0; j < W-A; j++) {
      cout << "0";
    }
    cout << "\n";
  }

  return 0;
}



Measured memory_bytes: 1280
# https://atcoder.jp/contests/abc055/tasks/arc069_b

# 先頭の2つの動物を仮定すれば後は決定的に決まる
# 決定的に決めた後に成り立つかどうか判定すれば良い 具体的にはs[0]と生成した文字列SのS[-1],S[0],S[1]を調べればよい
N = int(input())
s = input()


def simu(ret):
    for i, ss in enumerate(s[1:] + s[:1], start=1):
        if ret[i] == 'S' and ss == 'o':
            ret += ret[i - 1]
        elif ret[i] == 'S' and ss == 'x':
            ret += 'W' if ret[i - 1] == 'S' else 'S'
        elif ret[i] == 'W' and ss == 'o':
            ret += 'W' if ret[i - 1] == 'S' else 'S'
        elif ret[i] == 'W' and ss == 'x':
            ret += ret[i - 1]
    return ret


def check(ret):
    if ret[-2] != ret[0]:  # 回ってきたときに一致しないということはだめということ
        return False
    if ret[-1] != ret[1]:
        return False
    return True
    # ここの大量の条件分岐はらくできそう
    # if ret[0] == 'S' and ss == 'o':
    #     return ret[-2] == ret[1]
    # elif ret[0] == 'S' and ss == 'x':
    #     return ret[-2] != ret[1]
    # elif ret[0] == 'W' and ss == 'o':
    #     return ret[-2] != ret[1]
    # elif ret[0] == 'W' and ss == 'x':
    #     return ret[-2] == ret[1]


# パターン1
for ret in ['SS', 'SW', 'WS', 'WW']:
    ret1 = simu(ret)
    # print(ret1)
    if check(ret1):
        print(ret1[:-2])
        exit()
print(-1)


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), b(n), c(n);
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	rep(i, n) {
		dp[i + 1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
		dp[i + 1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
		dp[i + 1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
	}
	ll ans = 0;
	rep(i, 3) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13456
#include<stdio.h>
int main(){
	int n,m=100000,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		m=m+m*0.05;
		if(m%1000!=0){
				m=m/1000;
				m=m*1000+1000;
			}
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int x=s.size();
    vector<char>sen;
    for(int i=0;i<x;i++){
        if(s[i]=='0')sen.push_back('0');
        else if(s[i]=='1')sen.push_back('1');
        else if(sen.begin()!=sen.end()){sen.pop_back();}
    }
    int len=sen.size();
    for(int i=0;i<len;i++){
        cout<<sen.at(i);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] D = scanner.next().toCharArray();
    int K = scanner.nextInt();
    int N = D.length;
    int[][][] dp = new int[2][N + 1][K + 1];
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; i++) {
      for (int k = 0; k <= K; k++) {
        if (D[i - 1] == '0') {
          dp[0][i][k] = dp[0][i - 1][k];
          dp[1][i][k] = dp[1][i - 1][k];
          if (k > 0) dp[1][i][k] += 9 * dp[1][i - 1][k - 1];
        } else {
          if (k > 0) dp[0][i][k] = dp[0][i - 1][k - 1];
          dp[1][i][k] = dp[1][i - 1][k] + dp[0][i - 1][k];
          if (k > 0) dp[1][i][k] += 9 * dp[1][i - 1][k - 1]+ (D[i - 1] - '1') * dp[0][i - 1][k - 1];
        }
      }
    }
    System.out.println(dp[0][N][K] + dp[1][N][K]);
  }
}


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

#define PI 3.14159265359
/*
*/

int main() {
	int R;
	cin >> R;
	cout << fixed << setprecision(10);
	cout << 2 * PI * R << endl;

}

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#include <map>
#include <unordered_map>
#include <cstring>
#include <ctime>

using namespace std;

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define mp make_pair
#define pb push_back
#define fi first
#define sd second
#define fu(A, B, C) for(ll (A) = (B); (A) < (C); (A)++)
#define fu0(A, B) fu((A), 0, (B))
#define fd(A, B, C) for(ll (A) = (B); (A) >= (C); (A)--)
#define mem(A, B) memset((A), (B), sizeof((A)))
#define v(A, B, C) vector<ll> (A)((B), (C))
#define v2d(A, B, C) vector<vector<int>> (A)((B), vector<int> (C));
#define all(x) x.begin(), x.end()

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;

void performD() {
    ll n, k; cin >> n >> k;
    vector<ll> vals(n);
    for(ll& i : vals) cin >> i;
    ll mark[n];
    memset(mark, -1, sizeof(mark));
    ll it = 0, ct = 0;
    while (mark[it] == -1) {
        mark[it] = ct;
        ct++;
        if (ct == k) {
            cout << it+1 << endl;
            return;
        }
        it = vals[it]-1;
    }
    ll period = ct - mark[it];
    ll in = mark[it];
    k -= in;
    cout << "In = " << in << endl;
    cout << "Period = " << period << endl;
    ll search = k % period;
    ll j = 0;
    while (j < search) {
        it = vals[it]-1;
        j++;
    }
    cout << it+1 << endl;
    return;
}

vector<pair<int, vector<ll>>> vec;
int X;

ll dfs(int choice, vector<ll> m) {
  //cout << choice << endl;
  if (choice == vec.size()) {
    //fu0(i, m.size()) cout << m[i] << " "; cout << endl;
    fu0(i, m.size()) if (m[i] < X) return INT_MAX;
    return 0;
  }
  ll a = dfs(choice + 1, m);
  fu0(i, m.size()) {
    m[i] += vec[choice].second[i];
  }
  ll b = vec[choice].first + dfs(choice + 1, m);
  //cout << a << " " << b << endl;
  return min(a, b);
}

void performC() {
  ll n, m, x; cin >> n >> m >> x;
  X = x;
  vector<ll> maxes(m);
  fu0(i, n) {
    ll c; cin >> c;
    vector<ll> entry(m);
    fu0(i, m) {
      cin >> entry[i];
      maxes[i] += entry[i];
    }
    vec.pb(mp(c, entry));
  }
  fu0(i, maxes.size()) {
    if (maxes[i] < X) {
      cout << -1 << endl;
      return;
    }
  }
  vector<ll> empty(m, 0);
  cout << dfs(0, empty) << endl;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t = 1; //cin >> t;
  while(t--) {performC();}
}


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

int main() {
    int A,B,K;
    cin >> K;
    cin >> A >> B;
  
    if(K != 1){
    if(A % K == 0 || B % K == 0){
    cout << "OK" << endl;
    }
    else if(A / K == B / K){
    cout << "NG" << endl;
    }
    else{
    cout << "OK" << endl;
    }
   }
    
  if(K == 1){
    cout << "OK" << endl;
    }
}


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

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


Measured memory_bytes: 256
N = int(input())
T, A = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    ansT = T - H[ans] * 0.006
    candT = T - H[i] * 0.006
    if abs(A - ansT) > abs(A - candT):
        ans = i

print(ans+1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,a,b,c;cin>>n>>a>>b>>c;
    string s[n];
    string t[n];
    rep(i,0,n-1){
        cin>>t[i];
    }
    rep(i,0,n-1){
        if(t[i]=="AB"){
            if(a==0 && b==0){
                cout<<"No"<<endl;
                return 0;
            }else{
                if(a==1 && b==1 && i<n-1){
                    if(t[i+1]=="BC"){
                        a--;
                        b++;
                        s[i]='B';
                    }else{
                        a++;
                        b--;
                        s[i]='A';
                    }
                }else if(a<=b){
                    a++;
                    b--;
                    s[i]='A';
                }else{
                    a--;
                    b++;
                    s[i]='B';
                }
            }
        }else if(t[i]=="BC"){
            if(c==0 && b==0){
                cout<<"No"<<endl;
                return 0;
            }else{
                if(c==1 && b==1 && i<n-1){
                    if(t[i+1]=="AB"){
                        c--;
                        b++;
                        s[i]='B';
                    }else{
                        c++;
                        b--;
                        s[i]='C';
                    }
                }else if(c<=b){
                    c++;
                    b--;
                    s[i]='C';
                }else{
                    c--;
                    b++;
                    s[i]='B';
                }
            }
        }else if(t[i]=="AC"){
            if(a==0 && c==0){
                cout<<"No"<<endl;
                return 0;
            }else{
                if(a==1 && c==1 && i<n-1){
                    if(t[i+1]=="AB"){
                        a++;
                        c--;
                        s[i]='A';
                    }else{
                        a--;
                        c++;
                        s[i]='C';
                    }
                }else if(a<=c){
                    a++;
                    c--;
                    s[i]='A';
                }else{
                    a--;
                    c++;
                    s[i]='C';
                }
            }
        }
        //cout<<a<<' '<<b<<' '<<c<<endl;
    }
    cout<<"Yes"<<endl;
    rep(i,0,n-1){
        cout<<s[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 9916
from collections import defaultdict


class UnionFind:
    def __init__(self, n=0):
        self.d = {i: -1 for i in range(n)}

    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if (x == y):
            return False
        if (self.d[x] > self.d[y]):
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.d[self.find(x)]


N, M, K = map(int, input().split(' '))
deg = defaultdict(int)
to = defaultdict(list)
uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.unite(a, b)

for _ in range(K):
    c, d = map(int, input().split(' '))
    c -= 1
    d -= 1
    to[c].append(d)
    to[d].append(c)

for i in range(N):
    ans = uf.size(i) - 1 - deg[i]
    for u in to[i]:
        if uf.same(i, u):
            ans -= 1
    print(ans, end=' ' if i != (N - 1) else '\n')


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

using Graph=vector<vector<int>>;
vector<int64_t> cnt;
map<int,int64_t> S;

//親pを持つ頂点vから初めてカウンタを求める
void counter(Graph &G,int v,int p){
  
  cnt[v]=cnt[p]+S[v];
  
  for(auto nv:G[v]){
    if(nv==p) continue;
    counter(G,nv,v);
  }
  
}


int main(){
  //入力
  int N,Q;
  cin>>N>>Q;
  Graph G(N+1);
  for(int i=0;i<N-1;++i){
    int a,b;
    cin>>a>>b;
    G[b].push_back(a);
    G[a].push_back(b);
  }
  G[1].push_back(0);
  
  for(int i=0;i<Q;++i){
    int p;
    int64_t x;
    cin>>p>>x;
    S[p] += x;
  }


  cnt.assign(N+1,0);
  counter(G,1,0);

  for(int i=1;i<=N;++i){
    cout<<cnt[i]<<" ";
  }

}

Measured memory_bytes: 46080
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


string s;


signed main(){
    cin >> s;
    rep(i, 0, SZ(s)) cout << 'x';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
	int Top;
	int Bottom;
	int North;
	int East;
	int West;
	int South;
}Dice;
	
Dice D;
int setDice(int t,int b,int n,int e,int w,int s);
int RotDice(char str[]);

int main(){

	int ntrial;
	char str[10];
	int i;
	int score;
	
	while(scanf("%d\n",&ntrial)!=EOF){
		if(!ntrial)break;
		score=1;
		setDice(1,6,5,3,4,2);
		for(i=0;i<ntrial;i++){
			scanf("%[^\n]\n",str);
			score+=RotDice(str);
		}
		printf("%d\n",score);
	}
	return 0;
}


int setDice(int t,int b,int n,int e,int w,int s){

	D.Top=t;
	D.Bottom=b;
	D.North=n;
	D.East=e;
	D.West=w;
	D.South=s;
	return 0;

}

int RotDice(char s[]){
	char Jdg=s[0];
	
	if(Jdg=='N')setDice(D.South ,D.North ,D.Top   ,D.East  ,D.West  ,D.Bottom);
	if(Jdg=='E')setDice(D.West  ,D.East  ,D.North ,D.Top   ,D.Bottom,D.South );
	if(Jdg=='W')setDice(D.East  ,D.West  ,D.North ,D.Bottom,D.Top   ,D.South );
	if(Jdg=='S')setDice(D.North ,D.South ,D.Bottom,D.East  ,D.West  ,D.Top   );
	if(Jdg=='R')setDice(D.Top   ,D.Bottom,D.West  ,D.North ,D.South ,D.East  );
	if(Jdg=='L')setDice(D.Top   ,D.Bottom,D.East  ,D.South ,D.North ,D.West  );

	return D.Top;

}

Measured memory_bytes: 604
package main

import "fmt"

func primeFactorization(x int) map[int]int {
	ret := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			x /= i
			ret[i] += 1
		}
	}
	if x > 1 {
		ret[x] += 1
	}
	return ret
}

func main() {
	var N int
	fmt.Scan(&N)
	p_counts := primeFactorization(N)

	A := make([]int, 15)
	A[0] = 0
	for i := 1; i < 15; i++ {
		A[i] = A[i-1] + i
	}

	s := 0
	for _, c := range p_counts {
		for i := 1; i < 15; i++ {
			if c < A[i] {
				s += i - 1
				break
			}
		}
	}
	fmt.Println(s)
}


Measured memory_bytes: 1824