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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define W while
#define For(i,s,x) for(int i=s;i<x;i++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define Rof(i,s,x) for(int i=s;i>=x;i--)
#define pb push_back
#define F first
#define S second
#define nextl cout<<"\n"
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define deb(x) cout<<#x<<"="<<x<<"\n";


int main() {
	FASTIO;
    ll n;
    get(n);
    string s;
    get(s);
    ll t=0;
    if(n%2==1) t++;
    else FOR(i,n/2) if(s[i]!=s[n/2+i]&&++t) break;
    if(t) cout<<"No"; else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

class BellmanFord {
 private:
  const ll INF = 1LL << 60;
  int n_;
  vector<tuple<int, int, ll>> edges_;
  vector<vector<int>> to_, rto_;
  vector<ll> dist_;
  vector<bool> reachableFromSrc_, reachableToDst_;

  void dfs(int u, const vector<vector<int>>& to, vector<bool>& reachable) {
    if (reachable[u]) return;
    reachable[u] = true;
    for (int v : to[u]) {
      dfs(v, to, reachable);
    }
  }

 public:
  BellmanFord(int n)
      : n_(n),
        dist_(n, INF),
        to_(n),
        rto_(n),
        reachableFromSrc_(n, false),
        reachableToDst_(n, false) {}

  void addEdge(int u, int v, ll w) {
    edges_.emplace_back(u, v, w);
    to_[u].emplace_back(v);
    rto_[v].emplace_back(u);
  }

  bool exec(int src, int dst, ll& ans) {
    // To remove edges which is not involved in path from src to dst
    dfs(src, to_, reachableFromSrc_);
    dfs(dst, rto_, reachableToDst_);

    dist_[src] = 0;
    rep(i, n_) {
      for (auto& e : edges_) {
        int u = get<0>(e);
        int v = get<1>(e);
        ll w = get<2>(e);
        if (reachableFromSrc_[u] && reachableFromSrc_[v] &&
            reachableToDst_[u] && reachableToDst_[v]) {
          if (dist_[v] > dist_[u] + w) {
            dist_[v] = dist_[u] + w;
          }
        }
      }
    }
    for (auto& e : edges_) {
      int u = get<0>(e);
      int v = get<1>(e);
      ll w = get<2>(e);
      if (reachableFromSrc_[u] && reachableFromSrc_[v] && reachableToDst_[u] &&
          reachableToDst_[v]) {
        if (dist_[v] > dist_[u] + w) {
          // has negative cycle
          return true;
        }
      }
    }
    // no negative cycle
    ans = dist_[dst];
    return false;
  }
};

int main() {
  //
  int n, m;
  ll p;
  cin >> n >> m >> p;
  BellmanFord g(n);

  rep(i, m) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--;
    b--;
    c -= p;
    c = -c;
    g.addEdge(a, b, c);
  }
  ll ret = 0;
  if (g.exec(0, n - 1, ret)) {
    cout << -1 << endl;
  } else {
    cout << max(0LL, -ret) << endl;
  }

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<typename Monoid, typename OP = function<Monoid(Monoid, Monoid)> >
struct SegmentTree {
    //    using OP = function<Monoid(Monoid, Monoid)>;
    
    vector<Monoid> tree;
    int size;
    const OP merge_monoid; // bin' operation
    const Monoid e; // neutral element
                                           
    SegmentTree(const Monoid &e, const OP &f):
        merge_monoid(f), e(e) {};
    void init(int nmemb) {
        size = nmemb;
        tree.assign(size << 1, e);
    };

    template<class InputIterator>
    SegmentTree(InputIterator first, InputIterator last,
                const Monoid &e, const OP &f):
        size(distance(first, last)), merge_monoid(f), e(e)
    {
        tree.resize(size << 1);
        int i;

        i = size;
        for (InputIterator itr = first; itr != last; itr++) {
            tree[i++] = *itr;
        }

        for (i = size - 1; i > 0; i--) {
            tree[i] = merge_monoid(tree[(i << 1)], tree[(i << 1) | 1]);
        }
    };

    inline void update(int k, Monoid dat) {
        k += size;
        tree[k] = dat;
        
        while(k > 1) {
            k >>= 1;
            tree[k] = merge_monoid(tree[(k << 1)], tree[(k << 1) | 1]);
        }
    };

    // [l, r)
    inline Monoid fold(int l, int r) {
        l += size; //points leaf
        r += size;

        Monoid lv = e;
        Monoid rv = e;
        while (l < r) {
            if (l & 1) lv = merge_monoid(lv, tree[l++]);
            if (r & 1) rv = merge_monoid(tree[--r], rv);

            l >>= 1;
            r >>= 1;
        }

        return merge_monoid(lv, rv);
    };

    inline Monoid operator[] (const int k) const {
        return tree[k + size];
    };
};
//===

vector<SegmentTree<llong>> st(32,
                              SegmentTree<llong> (0, [](auto l, auto r){ return l + r; }));

int main() {
    llong n, q;
    string s;
    llong com;
    llong idx;
    char ch;
    llong l, r;

    cin >> n >> s;

    for (int i = 'a'; i <= 'z'; i++) {
        st[i - 'a'].init(s.length());
    }
    for (int i = 0; i < s.length(); i++) {
        st[s[i] - 'a'].update(i, 1);
    }

    cin >> q;
    while (q--) {
        cin >> com;

        if (com == 1) {
            cin >> idx >> ch;
            idx--;
            st[s[idx] - 'a'].update(idx, 0);
            s[idx] = ch;
            st[s[idx] - 'a'].update(idx, 1);
        }
        else {
            cin >> l >> r;
            l--;

            llong ans = 0;
            for (int i = 'a'; i <= 'z'; i++) {
                ans += (st[i - 'a'].fold(l, r) > 0 ? 1 : 0);
            }

            cout << ans << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 204164
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
        int N,W;
        Scanner in=new Scanner(System.in);
        N=in.nextInt();
        W=in.nextInt();
        int[] w=new int[N];
        int[] v=new int[N];
        for(int i=0;i<N;i++){
            w[i]=in.nextInt();
            v[i]=in.nextInt();
        }
        long[][] dp=new long[N+1][W+1];
        for(int i=0;i<N;i++){
            for(int j=1;j<=W;j++){
                if(j<w[i])dp[i+1][j]=dp[i][j];
                else dp[i+1][j]=Math.max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
        System.out.println(dp[N][W]);
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A,B; cin >>A>>B;
    

    cout << (B%A==0?A+B:B-A) << endl;
}


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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP1(i, n) for (int i = 1; i <= (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define CEIL(a, b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n, k;
	cin >> n >> k;
	vi x(n);
	REP(i, n)
		cin >> x[i];
	int ans = INF;
	REP(i, n - k + 1)
	{
		if (x[i + k - 1] < 0)
			ans = min(ans, -x[i]);
		else if (x[i] > 0)
			ans = min(ans, x[i + k - 1]);
		else
			ans = min(ans, min(abs(x[i]),abs(x[i + k - 1])) + x[i + k - 1] - x[i]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 640
// problem: "https://atcoder.jp/contests/abc129/tasks/abc129_c"

#include<bits/stdc++.h>
#define ll long long
#define p 1000000007

using namespace std;

ll numWays(int n,vector<ll>&V)
{
    if(n<=0)
        return 1;

    if(V[n] == -1)
        V[n] = (numWays(n-1,V)+numWays(n-2,V))%p;

    return V[n];
}

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

    vector<ll>V(n+1,-1);
    V[1] = 1;
    int i;
    for(i=0;i!=m;i++)
    {
        int x;
        cin>>x;
        V[x] = 0;
    }

    cout<<numWays(n,V);     // define

    return 0;
}


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

int main()
{
	string strInput;
	string strPat;
	cin >> strInput >> strPat;
	strInput += strInput;
	if (strInput.find(strPat) != string::npos)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int x=max(max(a,b),c);
  int other=a+b+c-x;
  for (int i=0;i<k;i++){
    x*=2;
  }
  cout << other+x << endl;
}

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

int main() {
  int N;
  cin >> N;
  int r = N % 10;
  int d = N % 1000;
  if ((N - r) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if ((d % 111 == 0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }     
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, lint>>>;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
const double PI = 3.1415926535897932;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

lint g[510][510];


// [l, r]
void f(lint l, lint r, lint level){
  if(l == r) return;
  lint n = r - l + 1;
  lint mid = (r + l) / 2;
  
  // [l, mid]
  // [mid + 1, r]
  for(lint i = l; i <= mid; i++){
    for(lint j = mid + 1; j <= r; j++){
      g[i][j] = level;
    }
  }

  f(l, mid, level + 1);
  f(mid + 1, r, level + 1);
}

int main(){
  
  rep(i, 510) rep(j, 510) g[i][j] = -1;
  lint n; cin >> n;

  f(1, n, 1);
  
  for(lint i = 1; i <= n; i++){
    for(lint j = i + 1; j <= n; j++){
      if(j != n) cout << g[i][j] << " ";
      else cout << g[i][j];
    }
    if(i != n) cout << endl;
  }

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

vector<ll> A;

void dfs(ll x){
    A.emplace_back(x);
    if(x * 10 > 4234566667){
        return ;
    }
    dfs(x*10 + x % 10);
    if(x % 10 == 0){
        dfs(x * 10 + 1);
    }else if(x % 10 == 9){
        dfs(x * 10 + x % 10 - 1);
    }else{
        dfs(x * 10 + x % 10 + 1);
        dfs(x * 10 + x % 10 - 1);
    }
}

int main(){
    ll K;
    cin >> K;
    rep(i,9) dfs(i+1);
    sort(ALL(A));
    A.erase(unique(ALL(A)),A.end());
    cout << A[K-1] << endl;
}


Measured memory_bytes: 1400
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Control.Arrow

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main = do
    [n,k] <- r'

    as <- r n
    reach <- U.thaw $ U.replicate n (-1)

    (posS,hdS,repS) <- count as reach 0 1
    let rm =  (k - hdS) `mod` repS 
    print $ if k < hdS then trace as 1 k else trace as posS rm 

count as reach ac pos = do
    h <- UM.read reach (pos-1)
    if h == -1
        then do 
            UM.write reach (pos-1) ac
            count as reach (ac+1) (as U.! (pos-1))
        else return (pos,h,ac-h)

trace as pos 0 = pos
trace as pos n = trace as (as U.! (pos-1)) (n-1)


Measured memory_bytes: 11540
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return;
		vector<tuple<int,string,int>> inputs;
		REP(i, n) {
			string a;
			cin >> a;
			int b, c;
			cin >> b >> c;
			c -= b - 1;
			inputs.push_back(make_tuple(c, a, b));
		}
		sort(ALL(inputs));
		REP(i, m) {
			int a;
			cin >> a;
			int ok = 0;
			for (int q = inputs.size() - 1; q >= 0; --q) {
				if (get<0>(inputs[q]) <= a&&a - get<0>(inputs[q]) + 1 <= get<2>(inputs[q])) {
					cout << get<1>(inputs[q]) << " " << a - get<0>(inputs[q]) + 1 << endl;
					ok = 1;
					break;
				}
			}
			if (ok == 0) {
				cout << "Unknown" << endl;
			}
		}
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3268
// AOJ 2150

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool prime[1000000];
void makeprime()
{
	fill(prime, prime + 1000000, true);
	prime[0] = prime[1] = false;
	for (int i = 4; i < 1000000; i+=2) prime[i] = false;
	for (int i = 3; i*i < 1000000; i += 2){
		if (prime[i]){
			for (int j = i*2; j < 1000000; j += i){
				prime[j] = false;
			}
		}
	}

	return;
}

int main(void)
{
	int n, p;
	makeprime();
	while (cin >> n >> p, (n != -1 && p != -1)){
		vector <int> primenum;
		for (int i = n+1; i < n + p + 500; i++){
			if (prime[i]){
				primenum.push_back(i);
			}
		}

		vector <int> ret;
		for (int i = 0; i < (int)primenum.size(); i++){
			for (int j = i; j < (int)primenum.size(); j++){
				ret.push_back(primenum[i] + primenum[j]);
			}
		}

		sort(ret.begin(), ret.end());

		cout << ret[p-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 2252
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

ll powmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int n;
string s;
void test() {
    cin >> n >> s;
    int pcnt=0;
    for (int i=0; i<n; ++i) {
        if (s[i]=='1') ++pcnt;
    }
    int s1=0, s2=0;
    for (int i=0; i<n; ++i) {
        if (s[i]=='1') {
            s1=(s1+(int)powmod(2,n-i-1,pcnt+1))%(pcnt+1);
            if (pcnt>1) {
                s2=(s2+(int)powmod(2,n-i-1,pcnt-1))%(pcnt-1);
            }
        }
    }
    for (int i=0; i<n; ++i) {
        int ans=1, si;
        if (s[i]=='0') {
            si=(s1+(int)powmod(2,n-i-1,pcnt+1))%(pcnt+1);
        }
        else if (pcnt==1) {
            cout << 0 << endl;
            continue;
        }
        else {
            si=(s2-(int)powmod(2,n-i-1,pcnt-1)+pcnt-1)%(pcnt-1);
        }
        // cout << si << ' ';
        while (si) {
            si=si%__builtin_popcount(si);
            ++ans;
        }
        cout << ans << endl;
    }
}

int main() {
    IOS;

    // int t; cin>>t;
    // while (t--) {
    //     test();
    // }

    // int t; cin>>t;
    // for (int i=1; i<=t; ++i) {
    //     cout<<"Case #"<<i<<": ";
    //     test();
    // }

    test();
    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int n;
    cin >> n;
    // int nMax = n;
    cout << n << ":";
    for (int i = 2; i*i <= n; i++) { // i

        // iが素数
        while (true) {
            if (n % i == 0) {
                n /= i;
                cout << " " << i;
            } else {
                break;
            }
        }

        OUT:
        ;
    }
    if (n != 1) {
        cout << " " << n;
    }
    cout << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  scanf("%d%d",&a,&b);
  if (abs(a-b) % 2 == 0) {
    cout << ((long long)a+b)/2 << endl;
  } else {
    cout << "IMPOSSIBLE\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

const int P = 998244353;
const int N = 3030;

using namespace std;

ll a, b, c, d;
ll dp[N][N];

int main(){

	cin >> a >> b >> c >> d;

	dp[a][b] = 1;

	for(ll i=a; i<=c; i++){
		for(ll j=b; j<=d; j++){
			if(i==a && j==b) continue;
			dp[i][j] = (dp[i-1][j]*j+dp[i][j-1]*i-(i-1)*(j-1)*dp[i-1][j-1])%P;
			dp[i][j] = (P+dp[i][j])%P;
		}
	}

	cout << dp[c][d] << '\n';

	return 0;
}


Measured memory_bytes: 74584
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MOD 1000000007
#define MAXN 2000000

LL fact[MAXN + 3];

LL fastExponentiation(LL base, int p) {
    if (p == 0)
        return 1;

    LL half = fastExponentiation(base, p/2);
    LL halfhalf = (half * half)%MOD;

    if (p%2 == 0)
        return halfhalf;
    else
        return (halfhalf * base)%MOD;
}

LL C(int n, int k) {
    LL numerator = fact[n];
    LL denominator = (fact[k] * fact[n - k])%MOD;
    return (numerator * fastExponentiation(denominator, MOD - 2))%MOD;
}


//Solve the problem for given grid size nxm and blocks.
LL solve(int n, int m, vector<pair<int, int> >& blocks) {
    fact[0] = 1;
    for (int i = 1; i <= MAXN; i++)
        fact[i] = (fact[i - 1] * i)%MOD;

    blocks.push_back({n, m});

    sort(blocks.begin(), blocks.end()); //sort in non-decreasing order of row and if tie by increasing order of column

    int k = (int) blocks.size();
    LL dp[k + 3]; //dp[i] = number of ways to go from (1, 1) to i-th block.

    //Initially we pretend there are no blocks.
    for (int i = 0; i < k; i++)
        dp[i] = C(blocks[i].first + blocks[i].second - 2, blocks[i].first - 1);

    //We add blocks one by one and update dp of affected blocks (ones on the right and down)
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k; j++) {
            if (i == j)
                continue;

            if (blocks[j].first >= blocks[i].first && blocks[j].second >= blocks[i].second) {
                int dr = blocks[j].first - blocks[i].first;
                int dc = blocks[j].second - blocks[i].second;


                //Number of ways to go to j decreased by number of ways to go to j that goes through i.
                LL ij = (dp[i] * C(dr + dc, dr)%MOD)%MOD;
                dp[j] = (dp[j] - ij + MOD)%MOD;
            }
        }
    }

    return dp[k - 1];
}

int main() {
    int n, m, k;

    cin >> n >> m >> k;

    vector<pair<int, int> > blocks;
    for (int i = 0; i < k; i++) {
        int r, c;
        cin >> r >> c;

        blocks.push_back({r, c});
    }

    cout << solve(n, m, blocks) << endl;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	if(n==1) cout<<"Hello World\n";
	else
	{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;	
	}
	return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    vector<bool> prime(1000001, true);
    for (int i = 2; i < 1000; i++) {
        if (prime[i]) {
            for (int j = i * 2; j < 1000001; j += i) prime[j] = false;
        }
    }
    vector<ll> primes(0);
    for (int i = 2; i < 1000000; i++) {
        if (prime[i]) primes.push_back(i);
    }
    int M = primes.size();
    //rep(i, 100) cout << primes[i] << " ";
    //cout << endl;
    int N;
    cin >> N;
    vector<ll> A(N), factor(1000000, 0);
    rep(i, N) {
        cin >> A[i];
        ll x = A[i];
        rep(j, M) {
            int p = primes[j];
            if (A[i] < p * p) {
                if (factor[x] == 0) factor[x] = 1;
                //cout << x << " 1" << endl;
                break;
            }
            int c = 0;
            while (x % p == 0) {
                x /= p;
                c++;
                //cout << "x=" <<  x << ", p=" << p << ", c=" << c << endl; 
            }
            if (c > factor[p]) factor[p] = c;
            //cout << A[i] << " " << primes[j] << " " << c << endl;
        }
    }
    /*
    rep(i, M) {
        if (factor[primes[i]] != 0) cout << primes[i] << " " << factor[primes[i]] << endl;
    }
    */
    ll lc = 1;
    rep(i, M) {
        rep(j, factor[primes[i]]) {
            lc = (lc * primes[i]) % MOD;
        }
    }
    //cout << lc << endl;
    ll ans = 0;
    rep(i, N) {
        ans = (ans + lc * mod_pow(A[i], MOD - 2, MOD)) % MOD;
    }
    cout << ans << endl;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var di = new Dictionary<long, long>();
		for(int i=1;i<N;i++){
			long v = A[0] + A[i] - i;
			if(di.ContainsKey(v) == false) di.Add(v, 0);
			di[v]++;
		}
		
		long cnt = 0;
		long criteria = 0;
		for(int i=1;i<N;i++){
			if(di.ContainsKey(criteria)) cnt += di[criteria];
			long v = A[0] + A[i] - i;
			di[v]--;
			criteria += A[i - 1] - A[i] - 1;
		}
		Console.WriteLine(cnt);
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 56688
cnt = int(input())
arr = input().split()

counter = 0
shouldBreak = False
while True:
    for i in range(len(arr)):
        if int(arr[i]) % 2 == 1:
            shouldBreak = True
            break;
        arr[i] = int(arr[i])/2
    if shouldBreak:
        break
    counter += 1

print(counter)

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 
    string s;
    cin>>s;
    int num=0;
    REP(i,s.size()){
        if(s[i]=='1') num++;
    }

    cout<<num<<endl;




}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int h,w;
	int x,y;
	while(1){
	scanf("%d",&h);
	scanf("%d",&w);
	if(h==0&&w==0){
	break;
	}
	for(y=0;y<h;y++){
		for(x=0;x<w;x++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  int a, b;
  a = n / 10;
  b = n - (n / 1000) * 1000;
  bool ok = false;
  if (a % 111 == 0) ok = true;
  if (b % 111 == 0) ok = true;
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> num(N);
  	ll sos[26]={1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        ll sum=1;
        for(int j=0;j<10;j++){
            sum=sum*sos[s[j]-'a'];
        }
        num[i]=sum;
    }
    sort(num.begin(),num.end());
    ll ans=0;
    ll cou=0;
    for(int i=1;i<N;i++){
        if(num[i]==num[i-1])cou++;
        if(num[i]!=num[i-1] || i==N-1){
            ans+=cou*(cou+1)/2;
            cou=0;
        }
    }
    cout << ans;


}

/*



 */



Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()
 
int main()
{
	int n,x;
	cin>>n>>x;
	vi m(n);
	rep(i,n){
		cin>>m.at(i);
	}
	sort(all(m));
	int ans=0;
	rep(i,n){
		x-=m.at(i);
		ans++;
	}
	ans+=x/m.at(0);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if ( a + b > c + d ) cout << "Left" << endl;
  else if ( a + b == c + d ) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    ll N,K;
    int ans=0;
    cin>>N>>K;
    while(N!=0){
        ans++;
        N = N/K;
    }
    cout<<ans;
    return 0;
}

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

public class MainClass
{
	public static void Main(string[] args)
	{
		string input = Console.ReadLine();
		
		if(input == "A")
			Console.WriteLine("T");
		if(input == "T")
			Console.WriteLine("A");
		if(input == "C")
			Console.WriteLine("G");
		if(input == "G")
			Console.WriteLine("C");
	}
}

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

int main()
{
    int n,m,x,dp[100006],cnt[100006];
    int mod=1000000007;
    memset(cnt,0,sizeof cnt);
    cin>>n>>m;
    for(int i=0;i<m;i++){ 
        cin>>x;
        cnt[x]=1;
    } 
    dp[0]=1;
    if(cnt[1]==0)dp[1]=1;
    else dp[1]=0;
    for(int i=2;i<=n;i++){ 
        if(cnt[i]==0){ 
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]%=mod;
    } }
    cout<<dp[n]<<'\n';
   
   
    return 0;
}


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

int main()
{
	int n, s = 0;
	int a[10];

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

	sort(a, a + n);

	for (int i = 0; i < n - 1; i++)
		s += a[i];

	if (s <= a[n - 1])
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}

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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;




int main(void)
{
	fastIO();

	int n;
	LL M[100010][3];
	LL dp[100010][3] = {0};

	cin >> n;

	FOR(i,0,n)
		cin >> M[i][0] >> M[i][1] >> M[i][2];

	dp[n-1][0] = M[n-1][0];
	dp[n-1][1] = M[n-1][1];
	dp[n-1][2] = M[n-1][2];

	FORI(i,n-2,0){
		dp[i][0] = M[i][0] + max(dp[i+1][1], dp[i+1][2]);
		dp[i][1] = M[i][1] + max(dp[i+1][0], dp[i+1][2]);
		dp[i][2] = M[i][2] + max(dp[i+1][0], dp[i+1][1]);
	}

	cout << max({dp[0][0], dp[0][1], dp[0][2]}) << endl;




	
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#define MAX 1000000
using namespace std;

int n,x,d[31];
bool p[MAX+1],dp[MAX+1];

void isPrime(){
   memset(p,1,sizeof(p));
   p[0] = p[1] = false;
   for(int i=2;i*i<=MAX;i++){
      for(int j=i+i;j<=MAX;j+=i)
         p[j] = false;
   }
}

int main(){
   isPrime();
   while(cin >> n >> x,n||x){
      memset(dp,0,sizeof(dp));
      for(int i=0;i<n;i++) cin >> d[i];
      
      dp[0] = true;
      for(int i=0;i<=x;i++){
         if(dp[i]){
            for(int j=0;j<n;j++){
               if(i + d[j] > x) continue;
               dp[i + d[j]] = true;
            }
         }
      }
      
      bool ju = true;
      for(int i=x;i>0;i--){
         if(p[i] && dp[i]){ cout << i << endl; ju = false; break; }
      }
      if(ju) cout << "NA" << endl;
   }
}

Measured memory_bytes: 3120
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] a = new int[M];
		int[] b = new int[M];
		
		int num1 = 0;
		int numN = 0;
		
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			if(a[i] == 1) {
				num1++;
			} else if(b[i] == N) {
				numN++;
			}
		}
		
		int[] a2 = new int[numN];
		int[] b2 = new int[num1];
		int x = 0;
		int y = 0;
		
		for(int i = 0; i < M; i++) {
			if(a[i] == 1) {
				b2[x] = b[i];
				x++;
			} else if(b[i] == N) {
				a2[y] = a[i];
				y++;
			}
		}
		
		int check = 0;
		Arrays.sort(a2);
		Arrays.sort(b2);
		
		loop:
		for(int i = 0; i < a2.length; i++) {
			int L = 0;
			int R = b2.length;
			while(L < R) {
				int m = (L + R) / 2;
				if(b2[m] == a2[i]) {
					System.out.println("POSSIBLE");
					check++;
					break loop;
				} else if(b2[m] > a2[i]) {
					R = m;
				} else if(b2[m] < a2[i]) {
					L = m + 1;
				}
			}	
		}
		if(check == 0) {
			System.out.println("IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 98376
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> l(n);
    REP(i, n) cin >> l[i];
    sort(all(l));
    int sum = 0;
    REP(i, n-1){
        sum += l[i];
    }
    cout << (sum > l[n-1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b;
    //切り上げ(一回で表す)
    /*(割られる数 - 1)/(割る数)*/
    c = (a + b + 2 - 1)/2;
    cout << c;
}

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

using namespace std;

int main(){
	int n, k, h, cnt = 0;
	scanf("%d %d",&n, &k);
	for (int i = 0; i < n; ++i){
		scanf("%d", &h);
		if (h >= k){
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a, b;
  if (n % 2 == 0) {
    for (ll i = 1; i <= n; i++) {
      for (ll j = i+1; j <= n; j++) {
	if (i + j != n + 1) {
	  a.push_back(i);
	  b.push_back(j);
	}
      }
    }
  }else {
    for (ll i = 1; i < n; i++) {
      for (ll j = i+1; j <= n; j++) {
	if (i + j != n) {
	  a.push_back(i);
	  b.push_back(j);
	}
      }
    }
  }
  cout << a.size() << endl;
  for (ll k = 0; k < (ll) a.size(); k++) {
    cout << a[k] << " " << b[k] << endl;
  }
  return 0;
}


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

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

Measured memory_bytes: 3624
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

const int N = 1e5 + 1;

int ct[N];

void testcase() {
    ll sum = 0;

    int n; cin >> n;
    rep (i, 0, n-1) {
        ll val; cin >> val;
        ct[val]++;
        sum += val;
    }

    int q; cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;

        ll cur = (ll) ct[b];
        sum -= (cur * b);
        ct[b] = 0;
        sum += (cur * c);
        ct[c] += cur;
        cout << sum << "\n";
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

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

    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    cout << a[2] * 10 + a[1] + a[0] << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 300111
#define inf 1000000000000000007

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	long long  n,m,k,ans =0 ,rb,cb;
	cin>>n>>m>>k;
	for(int i = 0 ; i <= n ; i++ ){
		for(int j =0 ; j <= m ;j++){
			ans = i*j + (n-i)*(m-j);
			if(ans == k || n*m - ans == k){
				cout<<"Yes";
				return 0;
			} 
		}
	}
	cout<<"No";
	return 0;	
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char s[101],s2[201],p[101];
	int i,j,flg,len1,len2,f2;
	scanf("%s",s);
	scanf("%s",p);
	len1=strlen(s);
	len2=strlen(p);
	strcpy(s2,s);
	strcat(s2,s);
//	printf("%s %s\n",s,p);
	f2=0;
	for(i=0;i<len1;i++)	{
		flg=1;
		for(j=0;j<len2;j++)	{
			if(s2[i+j]!=p[j])	{
				flg=0;
				break;
			}
		}
		if(flg==1)	{
			f2=1;
			break;
		}
	}
	if(f2==1)	printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 964
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n, k;
  cin >> n >> k;

  vector<bool> s(n, false);

  rep(i, k) {
    int d; cin >> d;
    rep(j, d) {
      int a;
      cin >> a; a--;
      s[a] = true;
    }
  }

  ll ans = 0;
  rep(i, n) {
    if (s[i] == false) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);

    long long x;
    long long p = 0;
    long long cur = 100;
    cin >> x;
    while(cur < x){
        cur += cur / 100;
        p ++;
    }
    cout << p << "\n";
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define MOD 1000000007
#define SIZE 5005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

vector <int> vec[SIZE];
int A[SIZE];
bool use[SIZE];
ll dp[SIZE],inv[SIZE];
ll cur[SIZE];
ll C[SIZE][SIZE];

void make()
{
	inv[1]=1;
	for(int i=2;i<SIZE;i++) inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
	for(int i=0;i<SIZE;i++)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
	}
}
int main()
{
	make();
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
		A[i]--;
		if(A[i]>=0)
		{
			vec[i].push_back(A[i]);
			vec[A[i]].push_back(i);
		}
	}
	vector <P> vx;
	ll ret=0;
	dp[0]=1;
	int c=0;
	for(int i=0;i<n;i++)
	{
		if(use[i]) continue;
		queue <int> que;
		que.push(i);
		use[i]=true;
		int sz=0;
		bool nm=true;
		while(!que.empty())
		{
			int v=que.front();que.pop();
			if(A[v]==-2) nm=false;
			sz++;
			for(int j=0;j<vec[v].size();j++)
			{
				int to=vec[v][j];
				if(!use[to])
				{
					use[to]=true;
					que.push(to);
				}
			}
		}
		//printf("%d %d\n",sz,nm);
		if(nm) ret++;
		else
		{
			c++;
			ret+=inv[n-1]*(ll) (sz-1)%MOD;
			ret+=dp[1]*(ll) sz%MOD*inv[n-1]%MOD;
			ret%=MOD;
			memset(cur,0,sizeof(cur));
			for(int j=n;j>=0;j--)
			{
				if(dp[j]==0) continue;
				cur[j+1]+=dp[j]*inv[n-1]%MOD*(ll) sz%MOD;
				cur[j+1]%=MOD;
				cur[j-1]+=dp[j]*(ll) j*(ll) (j-1)%MOD*(ll) sz%MOD*inv[n-1]%MOD;
				cur[j-1]%=MOD;
				cur[j]+=2LL*dp[j]*(ll) j*(ll) sz%MOD*inv[n-1]%MOD;
				cur[j]%=MOD;
			}
			for(int j=0;j<=n;j++) dp[j]=(cur[j]+dp[j])%MOD;
		}
	}
	ll ans=n-ret;
	if(ans<0) ans+=MOD;
	while(c--) ans=ans*(ll) (n-1)%MOD;
	printf("%lld\n",ans);
}

Measured memory_bytes: 120996
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;

class Main{
        public static void main(String args[]){
                Scanner scan = new Scanner(System.in);
                int N = scan.nextInt();
                ArrayList<Integer> card = new ArrayList<Integer>();
                //ArrayList<Integer> alice = new ArrayList<Integer>();
                //ArrayList<Integer> bob = new ArrayList<Integer>();
                int i;
                for(i=0;i<N;i++)card.add(scan.nextInt());
                Collections.sort(card);
                int A=0,B=0;
                for(i=N-1;;){
                        //alice.add(card.get(i));
                        A += card.get(i);
                        i--;
                        //System.out.println(i);
                        if(i==-1)break;
                        //bob.add(card.get(i));
                        B += card.get(i);
                        i--;
                        //System.out.println(i);

                        if(i==-1)break;
                }
                System.out.println(A-B);
        }
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

map<char, int> m;

int judge(char c1, char c2, vector<string> v) {
	int id = -1, res = -1;

	rep(i, v.size()) {
		if(v[i][1] == c1) {
			if(res < m[v[i][0]]) {
				res = m[v[i][0]];
				id = i;
			}
		}
	}

	if(id != -1) return id;

	rep(i, v.size()) {
		if(v[i][1] == c2) {
			if(res < m[v[i][0]]) {
				res = m[v[i][0]];
				id = i;
			}
		}
	}

	if(id != -1) return id;

	rep(i, v.size()) {
		if(res < m[v[i][0]]) {
			res = m[v[i][0]];
			id = i;
		}
	}
	return id;
}

int main() {
	char c;
	vector<vector<string> > v(4, vector<string>(13));

	REP(i, 1, 10) {
		m['0'+i] = i;
	}

	m['T'] = 10;
	m['J'] = 11;
	m['Q'] = 12;
	m['K'] = 13;
	m['A'] = 14;

	while(cin >> c) {
		if(c == '#') break;

		rep(i, 4) {
			rep(j, 13) {
				cin >> v[i][j];
			}
		}

		int a = 0, b = 0, id = 0;
		rep(i, 13) {
			vector<string> t;
			rep(j, 4) {
				t.push_back(v[j][i]);
			}

			id = judge(c, v[id][i][1], t);
			if(id & 1) {
				b++;
			} else {
				a++;
			}
		}

		if(a > b) {
			cout << "NS " << a - 6 << endl;
		} else {
			cout << "EW " << b - 6 << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 1204