akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(auto i=(a); i<(b); i++)
#define dec(i,n,a) for(auto i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 3e-8
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 101010
#define LOGN 29
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;


struct shash{
    vi suf, b;
    int mod;
    shash(string& s, int base = 153, int _mod = 2038074743) {
        int n = s.length();
        suf.assign(n + 1, 0); // suf[n] = 0
        b.assign(n + 1, 0);
        b[0] = 1;
        b[1] = base;
        mod = _mod;
        dec(i,n-1,0) suf[i] = (s[i] + suf[i + 1] * b[1]) % mod;
        rep(i,2,n+1) b[i] = b[i - 1] * b[1] % mod;
    }
    inline int substr(int l, int r) const { // [l, r]
        return ((suf[l] - suf[r + 1] * b[r - l + 1])%mod + mod)%mod;
    }
};

int n, salvoL[666][666], salvoC[666][666];
char grid[666][666];
vector<shash> lin, col;

bool ok(int i, int j){
	rep(k,0,n) if(salvoL[i+k][j] != salvoC[j+k][i]) return 0;
	return 1;
}

int32_t main(){
	scanf("%lld", &n);
	rep(i,0,n) rep(j,0,n) scanf(" %c", &grid[i][j]);
	int N = 2*n-1;
	rep(i,0,N) rep(j,0,N) if(!(i<n && j<n)) grid[i][j] = grid[i%n][j%n];
	rep(i,0,N){
		string s = "";
		rep(j,0,N) s += grid[i][j];
		lin.pb(shash(s));
	}
	rep(i,0,N){
		string s = "";
		rep(j,0,N) s += grid[j][i];
		col.pb(shash(s));
	}
	rep(i,0,N) rep(j,0,n)
		salvoL[i][j] = lin[i].substr(j, j+n-1), 
		salvoC[i][j] = col[i].substr(j, j+n-1);
	int ans = 0;
	rep(i,0,n) rep(j,0,n)
		if(ok(i,j)) ans++;
	printf("%lld\n", ans);
}


Measured memory_bytes: 18560
import numpy as np
H,W = [ int(it) for it in input().split() ]
x = np.array([ [0 if v == "." else 1 for v in input() ] for i in range(H)]).astype(np.int32)
Close = np.zeros(x.shape).astype(np.int32)
fcost = np.zeros(x.shape).astype(np.int32)+10000
fcost[0,0]=0


gx,gy=(x.shape[0]-1,x.shape[1]-1  )

Open=[(0,0,-1)]
dw=[[0,1],[0,-1],[1,0],[-1,0]]


FLAG_END = False
BREAK = False

Open.sort(key=lambda x:-x[2])
nx,ny,_ =  Open.pop()
for i in range(100000):
    while ( Close[nx,ny]==1 ):
        if ( len(Open)==0):
            print (-1)
            BREAK=True
            break
        Open.sort(key=lambda x:-x[2])
        nx,ny,_ =  Open.pop()
    if BREAK:
        break
    Close[nx,ny]=1
    for dx,dy in dw:
        mx,my=nx+dx,ny+dy
        if ( 0<=mx and mx<x.shape[0] and  0<=my and my<x.shape[1] ):
            if ( Close[mx,my] == 0 and x[mx,my]==0 ):
                fcost[mx,my]=min(fcost[mx,my],fcost[nx,ny]+1)
                Open.append( (mx,my,abs(mx-gx)+abs(my-gy)+fcost[mx,my])  )   
                if (mx==gx and my==gy):
                    FLAG_END = True
                    break
    if (FLAG_END):
        break
if (FLAG_END):
    print (x.shape[0]*x.shape[1]-np.sum(x)-fcost[gx,gy]-1 )

Measured memory_bytes: 12560
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(A);
	READV(B);
	cout<<max({A+B,A-B,A*B})<<endl;

	return 0;
}

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

map<string, string> mp;

int main()
{
    mp["Sunny"] = "Cloudy";
    mp["Cloudy"] = "Rainy";
    mp["Rainy"] = "Sunny";
    string s;
    cin >> s;
    cout << mp[s] << "\n";
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void) {
	char c;
    while(scanf("%c", &c) != EOF){
    	if(c >= 'A' && c <= 'z'){
    		if(c <= 'Z'){
    			printf("%c",c - 'A' + 'a');
    		}
    		else if(c >= 'a'){
    			printf("%c",c - 'a' + 'A');
    		}
    	}
    	else printf("%c",c);
    }
	return 0;
}

Measured memory_bytes: 524
#!/usr/bin/env python3
import sys
import numpy as np
import fractions

def solve(A: int, B: int):
    print(A*B//fractions.gcd(A,B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13576
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(final String[] args) {
        final Task task = new Task();
        task.solve();
    }
}

class Task {

    public void solve() {
        try(final Scanner scanner = new Scanner(System.in);) {
            final int n = scanner.nextInt();

            final Set<Integer> input = IntStream.rangeClosed(1, n).map(i -> scanner.nextInt()).boxed()
                    .collect(Collectors.toSet());
            System.out.println(input.size());
        }
    }
}


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

const ll INF = 1e18;
const int MX = 2005;

int n,m,q;
ll ans = 0;
vector<int>a;
vector<int>b;
vector<int>c;
vector<ll>d;
int cnt = 0;

ll cal(vector<int>A){
  ll res = 0;
  rep(i,q){
    if(A[b[i]-1] - A[a[i]-1] == c[i]){
      res += d[i];
    }
  }
  return res;
}

int make(int i,int j,vector<int>A){
  if(j == n){
    ans = max(ans,cal(A));
    return 0;
  }
  if(i == m+1){
    return 0;
  }
  make(i+1,j,A);
  A.push_back(i);
  make(i,j+1,A);
  make(i+1,j+1,A);
  return 0;
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  vector<int>A;
  make(1,0,A);
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve(void)
{
  int N;cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  } 
  int MAX = 0;
  int MAX_cnt;
  int MAX_index;
  int MAX_next = -1;
  for (int i = 0; i < N; i++)
  {
    if(MAX < vec[i])
    {
      MAX_next = MAX;
      MAX = vec[i];
      MAX_index = i;
      MAX_cnt = 1;
    }
    else if(MAX_next < vec[i])
    {
      MAX_next = vec[i];
    }

  }
  if(MAX_cnt > 1)
  {
    for (int i = 0; i < N; i++)
    {
      cout<<MAX<<endl;
    }
  }
  else
  {
    for (int i = 0; i < N; i++)
    {
      if(MAX_index == i)
      {
        cout<<MAX_next<<endl;
      }
      else
      {
        cout<<MAX<<endl;
      }
      
    }
    
  }
  

  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3200
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,a,ans=1e18;
const int big=1e18;
signed main(){
	cin>>n>>a;ans=n;
	for(int i=1;i<=1000;i++){
//		cerr<<i<<" "<<ans<<endl;
		if(ans<a*i)break;
		int len=i+1;
		int v;
		for(int j=2;;j++){
//			cerr<<j<<endl;
			int now=1;
			bool ok=false;
			for(int k=1;k<=len;k++){
				if(now>big/j)ok=true;
				now=now*j;
			}
			ok|=(now>=n);
			if(ok){
				v=j;
				break;
			}
		}
		for(int j=0;j<=len;j++){
			int mul1=1,mul2=1;
			for(int k=1;k<=j;k++){
				mul1*=v;
			}
			for(int k=j+1;k<=len;k++){
				mul2*=(v-1);
			}
			if(mul1>big/mul2 || mul1*mul2>=n){
				ans=min(ans,a*i+v*j+(v-1)*(len-j));
				break;
			}
		}
	}
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
main = do
  li <- getLine
  let [n,m] = map read $ words li
  lrs <- getLRs m
  let answer = compute lrs
  print answer

getLRs 0 = return []
getLRs k = do
  li <- getLine
  let [l,r] = map read $ words li
  lrs <- getLRs (pred k)
  return ((l,r):lrs)

compute lrs = max 0 (r - l + 1)
  where
    l = maximum $ map fst lrs
    r = minimum $ map snd lrs


Measured memory_bytes: 102524
#include <bits/stdc++.h>
using namespace std; 
#define int int64_t
#define itn int
#define fi first
#define se second
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,d,ans=0,sum;
  int h,l;
  vector<int> a,b,c;
  cin>>n;
  for(int i=0;i<n;i++) cin>>d,a.push_back(d);
  for(int i=0;i<n;i++) cin>>d,b.push_back(d);
  for(int i=0;i<n;i++) cin>>d,c.push_back(d);
  sort(a.begin(),a.end()),sort(c.begin(),c.end());
  for(int i=0;i<n;i++){
    h=n,l=-1;
    sum=1;
    while(h-l>1){
      int m=(h+l)/2;
      if(a[m]>=b[i]) h=m;
      else l=m;
    }
    sum*=(h);
    h=n,l=-1;
    while(h-l>1){
      int m=(h+l)/2;
      if(c[m]<=b[i]) l=m;
      else h=m;
    }
    sum*=(n-h);
    ans+=sum;
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 6380
#include <bits/stdc++.h>
constexpr int MOD = 1000000007;
constexpr int MAX = 200010;
constexpr int DEBUG = 0;
using ll = long long;
using namespace std;

int n, k;
ll f[MAX], fn[MAX];

ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}

void init() {
    f[0] = 1;
    for (int i = 1; i < MAX; i++)
        f[i] = (f[i - 1] * i) % MOD;
    
    fn[0] = n;
    for (int i = 1; i < MAX; i++)
        fn[i] = fn[i - 1] * (n - i) % MOD;
}
int main() {
    cin >> n >> k;
    init();
    if (DEBUG >= 1) {
        for (int i = 0; i <= k; i++)
            cout << f[i] << " ";
        cout << endl;
        for (int i = 0; i <= k; i++)
            cout << fn[i] << " ";
        cout << endl;
    }
    ll total = 1;
    
    if (DEBUG >= 1) {
        cout << 1 << " * " << 1 << " : " << total << endl;
    }
    for (int i = 1; i <= min(n-1, k); i++) {
        // C(n,i) * H(n-i,i) = C(n,i) * C(n-1,i)
        ll c = (fn[i-1] * inv(f[i]) % MOD);
        ll h = (((fn[i-1] * (n-i)) % MOD * inv(n)) % MOD * inv(f[i]) % MOD);
        total += c * h;
        if (DEBUG >= 1) {
            cout << c << " * " << h << " : " << total << endl;
        }
        total %= MOD;
    }
    
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	long n;
	cin >> n;
	vector<long> a(n + 1);
	long answer = 0;

	for (int i = 0; i < n + 1; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		long b;
		cin >> b;
		if (b < a[i]) {
			answer += b;
          	a[i] -= b;
		}
		else if (b - a[i] < a[i + 1]) {
			answer += b;
			a[i + 1] = a[i + 1] - (b - a[i]);
          	a[i] = 0;
		}
		else {
			answer += a[i + 1] + a[i];
			a[i + 1] = 0;
          	a[i] = 0;
		}
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;

int binomialCoeff(int n, int k){
    if(n < k) return 0;
    int res = 1;
    if ( k > n - k )
        k = n - k;
    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
void solve(){
   int n;
   string s;
   cin >> n >> s;
   int nred = 0, nblue = 0, ngreen = 0;

   for(int i = 0; i < n; ++i){
       if(s[i] == 'R') ++nred;
       if(s[i] == 'G') ++ngreen;
       if(s[i] == 'B') ++nblue;
   }
//   cout << nred << " " << ngreen << " " << nblue << endl;
//   cout << binomialCoeff(nred,3) << " " << binomialCoeff(ngreen,3) << " " << binomialCoeff(nblue,3) << endl;
   int res = binomialCoeff(n,3) - binomialCoeff(nred,3) - binomialCoeff(ngreen,3) - binomialCoeff(nblue, 3) ;
//   cout << res<< endl;
   res -= binomialCoeff(nred,2)*(ngreen + nblue) + binomialCoeff(ngreen,2)*(nred + nblue) + binomialCoeff(nblue,2)*(ngreen + nred);
//   cout << res << endl;

   for(int i = 0; i < n; ++i){
       for(int j = 0; i + 2*j < n; ++j){
           if(s[i] == s[i + j] || s[i + j] == s[i + 2*j] || s[i] == s[i + 2*j]) continue;
           else --res;
       }
   }
   cout << res;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    vector<vector<int> > dp(N+1, vector<int>(W+1,0));
    rep(i, N) cin >> v.at(i) >> w.at(i);
    rep(i, N){
        rep(j, W+1){
            if(j < w.at(i)) {
                dp[i+1][j] = dp[i][j];
            }
            else {
                dp[i+1][j] = max(dp[i][j], dp[i+1][j-w.at(i)] + v.at(i));
            }
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 6868
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int d, n;
	cin >> d >> n;
	if (d == 0) {
		if (n == 100) {
			cout << 101;
		}
		else {
			cout << n << endl;
		}

	}
	else if(d == 1){
		if (n == 100) {
			cout << 10100 << endl;
		}
		else {
			cout << n * 100 << endl;
		}

	}
	else {
		if (n == 100) {
			cout << 1010000 << endl;
		}
		else {
			cout << n * 10000 << endl;
		}
	}
	
	/*
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	int ans = 0;
	rep(i, n) {
		int t = 0;
		while ((a[i] % 2) == 0) {
			t++;
			a[i] /= 2;
		}
		ans += t;
	}
	
	cout << ans << endl;
	*/
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio> 
#include <cstring>

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rangeRep(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
struct Student {
	int t, n, m, s;
};

constexpr int timeOffset = 540;
//[PC][time] = Student
int use[1000][1260 - timeOffset] = { 0 };


class Solve {
public:
	Solve() {};
	~Solve() {};

	void solver() {
		std::vector<std::vector<int>> results;
		while (1) {
			int n, m, r, q;
			std::vector<Student> students;
			std::cin >> n >> m;
			if (!n) break;

			std::memset(use, 0, sizeof(use));
			results.push_back(std::vector<int>());
			//login info
			std::cin >> r;
			Student s;
			rep(i, r) {
				//time, PC, student, isLogin
				std::cin >> s.t >> s.n >> s.m >> s.s;
				//login
				if (s.s) {
					//set login start time
					use[s.n - 1][s.t - timeOffset] = s.m;
				}//logout
				else {
					//Fill until login start time
					int time = s.t - timeOffset - 1;
					while (use[s.n - 1][time] == 0) {
						use[s.n - 1][time--] = s.m;
					} 
				}
			}

			//question [ts, te]
			std::cin >> q;
			rep(i, q) {
				int num = 0;
				int ts, te, m;
				std::cin >> ts >> te >> m;
				ts -= timeOffset; te -= timeOffset;
				//Check if logged in on any PC.
				rangeRep(j, ts, te) {
					rep(k, n) {
						if (use[k][j] == m) {
							num++;
							break;
						}
					}
				}
				results.back().push_back(num);
			}
		}

		for (auto& x : results) {
			for (auto& y : x) {
				std::cout << y << std::endl;
			}
		}
	}
private:

};

int main() {
	Solve solve;
	solve.solver();
	return 0;
}

Measured memory_bytes: 5792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(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;
}

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

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

ll calc(ll dp[][3],ll ch,ll ind,ll a[],ll b[],ll c[],ll n)
{
    if(ind>n) return 0;
    if(dp[ind][ch]!=-1) return dp[ind][ch];
    else
    {
        if(ch==0)
        {
           dp[ind][ch]=std::max(calc(dp,1,ind+1,a,b,c,n),calc(dp,2,ind+1,a,b,c,n)) ;
           dp[ind][ch]+=a[ind];
        }
        if(ch==1)
        {
            dp[ind][ch]=std::max(calc(dp,0,ind+1,a,b,c,n),calc(dp,2,ind+1,a,b,c,n));
            dp[ind][ch]+=b[ind];
        }
        if(ch==2)
        {
            dp[ind][ch]=std::max(calc(dp,1,ind+1,a,b,c,n),calc(dp,0,ind+1,a,b,c,n));
            dp[ind][ch]+=c[ind];
        }
        return dp[ind][ch];
    }
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,f,t,k;
    cin >> n ;
    ll a[n+1],b[n+1],c[n+1];
    repp(i,1,n+1) cin >> a[i] >> b[i] >> c[i] ;
    ll dp[n+1][3];
    memset(dp,-1,sizeof(dp));
    cout << std::max(calc(dp,0,1,a,b,c,n),std::max(calc(dp,1,1,a,b,c,n),calc(dp,2,1,a,b,c,n)));
    
    return 0;
}

Measured memory_bytes: 14336
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M, C = LI()
    B = LI()
    A = [LI() for _ in range(N)]

    ans = len([i for i in A if sum([i[j] * B[j] for j in range(M)]) + C > 0])
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9960
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt() - 1;
        int X = sc.nextInt();
        int min = X - K;
        int max = X + K;
        for (int i = min; i <= max; i++) {
        	System.out.print(i + " ");
        }
    }
}

Measured memory_bytes: 23764
<?php
$n = int();
if($n % 2 == 1){
    echo 0;
}else{
    $r = 0;
    for($i = 1; 2*5**$i <= 10**18;$i++){
        $r+=intdiv($n, 2*5**$i);
    }
    echo $r;
}
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4728
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
 
LL n, a[112345];
bool zero_flag = false;
LL sum, res, ans, a_c[112345];
 
int main()
{
	in >> n;
	rep(i, n) { in >> a[i]; }
 
	std::copy(a, a + n, a_c);
	{
		if (a[0] == 0)
		{
			zero_flag = true;
			++res;
			a[0] = 1;
		}
		if (a[0] < 0)
		{
			res +=1 - a[0];
			a[0] = 1;
		}
		sum = a[0];
		rep(i, n)
		{
			if (i == n - 1) { break; }
			if (sum <= 0 && sum + a[i + 1] <= 0)
			{
				LL want = abs(sum) + 1;
				res += abs(want - a[i + 1]);
				a[i + 1] = want;
			}
			else if (sum >= 0 && sum + a[i + 1] >= 0)
			{
				LL want = -(sum + 1);
				res += abs(a[i + 1] - want);
				a[i + 1] = want;
			}
			sum += a[i + 1];
		}
	}
	ans = res; res = 0;
	std::copy(a_c, a_c + n, a);
	{
		if (zero_flag)
		{
			++res;
			a[0] = -1;
		}
		if (a[0] > 0)
		{
			res += a[0] + 1;
			a[0] = -1;
		}
		sum = a[0];
		rep(i, n)
		{
			if (i == n - 1) { break; }
			if (sum <= 0 && sum + a[i + 1] <= 0)
			{
				LL want = abs(sum) + 1;
				res += abs(want - a[i + 1]);
				a[i + 1] = want;
			}
			else if (sum >= 0 && sum + a[i + 1] >= 0)
			{
				LL want = -(sum + 1);
				res += abs(a[i + 1] - want);
				a[i + 1] = want;
			}
			sum += a[i + 1];
		}
	}
	ans = std::min(ans, res);
 
	out << ans << std::endl;
	return 0;
}

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

int main()
{
    map<string,int>m1,m2;
    int n,m;cin >> n ;
    string c, w;
    for(int i=1;i<=n;i++)
    {
        cin >> c;
        m1[c]++;
    }
    cin >> m;
    for(int i=1;i<=m;i++)
    {
        cin >> w;
        for(auto i : m1)
        {
            if(i.first  == w)
            {
                m1[w]--;
            }
        }
    }
    int ans = -1e8;
    for(auto i : m1)
    {
        if(i.second > ans) ans = i.second;
    }

    cout << (ans >= 0 ? ans : 0) << endl;
    return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
table = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    table[a-1].append(b-1)
    table[b-1].append(a-1)
count = 0
for i in range(len(table)):
    for j in range(len(table[i])):
        if h[table[i][j]] >= h[i]:
            break
    else:
        count += 1
print(count)



Measured memory_bytes: 29400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define EPS 0.0001

int cnt[26];
int N;
int main() {
	cin >> N;
	REP(i, 0, N) {
		int a, b;
		cin >> a >> b;

		cout << 127 * (a - 1) + (a % 2 == 0 ? ~b & 127 : b) << endl;
	}
	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,m,s;
  while(cin >> h >> m >>s){
    if(h+m+s == -3) break;
    s = 7200 - (h * 3600 + m * 60 + s);
    cout<< setfill('0') << setw(2) << right<< s/3600 << ":" <<setfill('0') << setw(2) << right<< (s%3600)/60 << ":" <<setfill('0') << setw(2) << right<<(s%3600)%60<<endl;
    s *= 3;
    cout<< setfill('0') << setw(2) << right<< s/3600 << ":" <<setfill('0') << setw(2) << right<< (s%3600)/60 << ":" <<setfill('0') << setw(2) << right<<(s%3600)%60<<endl;
  }
  return 0;
}

Measured memory_bytes: 3084
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int h[] = new int[n];
		int h2[] = new int[n];
				
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			h2[i] = h[i];
		}
		
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			
			if(h[a] < h[b]) {
				h2[a] = 0;
			}
			if(h[a] > h[b]) {
				h2[b] = 0;
			}
			if(h[a] == h[b]) {
				h2[a] = 0;
				h2[b] = 0;
			}
		}
		
		int c = 0;
		for(int i = 0; i < n; i++) {
			
			if(h2[i] != 0) {
				c++;
			}
		}
		
		System.out.println(c);
	}
}

Measured memory_bytes: 60392
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;


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

    if (s.length() < t.length()) {
        cout << "LESS" << endl;
    } else if (s.length() > t.length()) {
        cout << "GREATER" << endl;
    } else {
        if (s < t) {
            cout << "LESS" << endl;
        } else if (s > t) {
            cout << "GREATER" << endl;
        } else {
            cout << "EQUAL" << endl;
        } 
    } 
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int a[n];
    rep(i,n) cin>>a[i];
    int x=0,y=0;
    int ans[h][w];
    rep(i,n){
        rep(j,a[i]){
            ans[x][y]=i+1;
            if(x%2==0){
                if(y==w-1){
                    x++;
                }
                else y++;
            }
            else{
                if(y==0) x++;
                else y--;
            }
        }
    }

    rep(i,h){
        rep(j,w){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        int A = i, B = N/A;
        if (A*B == N) {
            ans += B-1;
        }
        else {
            ans += B;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

ll get_count(ll K, const vector<ll> &a) {
    int n = a.size();
    ll ret = 0ll;
    rep(i,n) {
        ll b = K-a[i];
        auto itr = lower_bound(a.begin(), a.end(), b);
        ret += (a.end()-itr);
    }
    return ret;
}

ll get_sum(ll K, ll s, const vector<ll> &a, const vector<ll> &sum) {
    ll ret = 0;
    ll n = a.size();
    rep(i,n) {
        ll b = K-a[i];
        auto itr = lower_bound(a.begin(), a.end(), b);
        ll idx = itr-a.begin();
        ret += (s-sum[idx]);
        ll cnt = n-idx;
        ret += (a[i] * cnt);
    }
    return ret;
}

void test(const vector<ll> &a) {
    int n = a.size();
    vector<ll> ret;
    rep(i,n) {
        rep(j,n) {
            ret.push_back(a[i]+a[j]);
        }
    }
    sort(ret.begin(), ret.end(), greater<>());
    print(ret);
}

int main(int argc, char const *argv[]) {
    ll n,m; cin>>n>>m;
    vector<ll> a(n), sum(n+1,0);
    ll s = 0;
    rep(i,n) cin>>a[i], s+=a[i];
    sort(a.begin(), a.end());
    rep(i,n) sum[i+1] = sum[i]+a[i];
    // test(a);
    // binary search
    ll ok = 0; ll ng = LINF;
    while (abs(ok-ng)>1) {
        ll mid = (ok+ng)/2;
        ll cnt = get_count(mid,a);
        if (cnt>=m) ok = mid;
        else ng = mid;
    }

    ll K = ok;
    ll ans = get_sum(K,s,a,sum);
    ans -= (get_count(K,a)-m)*K;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      for(int i=0; i<n; i++)
        seq[i] = Integer.parseInt(br.readLine());

      System.out.println( shellSort(seq, n) );

      StringBuilder str = new StringBuilder(n*5);
      for (int i : seq)
        str.append(i).append("\n");
      str.setLength(str.length()-1);
      System.out.println(str);
    }
  }

  public static int shellSort(int a[], int n) {
    int cnt=0;
    int m = 0;
    int[] aG = new int[100];
    for (int g=1,max=n+1; g < max; g=(g*3+1)) {
      aG[m++] = g;
    }
    StringBuilder str = new StringBuilder(m*5);
    str.append(m).append("\n");

    for(int i=(m-1); i>-1; i--){
      cnt += insertionSort(a, n,aG[i]);
      str.append(aG[i]).append(" ");
    }

    str.setLength(str.length()-1);
    System.out.println(str);

    return cnt;
  }
  
  public static int insertionSort(int a[], int max, int g) {
    int cnt=0;

    for (int i=g,j=0,v=0; i < max; i++) {
      for( j=(i-g), v=a[i]; j>=0 && a[j]>v; j-=g ) {
        a[j+g] = a[j];
        cnt++;
      }
      a[j+g] = v;
    }

    return cnt;
  }
}


Measured memory_bytes: 87256
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000;

//関数

int main() {
    
    
    //入力
    string s;
    cin>>s;
    unsigned long K;
    cin>>K;
    
    //計算
    set<string> Huge;
    for(int length=1;length<=min(K,s.size());length++){
        for(int i=0;i<=s.size()-length;i++){
            Huge.insert(s.substr(i,length));
        }
    }
    auto ite=Huge.begin();
    advance(ite,K-1);
    cout<<*ite<<endl;
}

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

using namespace std;

typedef long long  ll;

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

    vector<int> abc(3);
    for (int i = 0; i < 3; ++i)
        cin >> abc[i];
    sort(abc.begin(), abc.end());

    if (abc[0] == 5 && abc[1] == 5 && abc[2] == 7)
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int H;
  std::cin >> H;
  int N = 2 * H - 1;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  int ok = 1, ng = N + 1;
  while (ng - ok > 1) {
    int md = (ok + ng) / 2;
    ([&] {
      std::vector<bool> base(N);
      for (int i: range(0, N)) {
        base[i] = (A[i] >= md);
      }
      int L = 0, R = N - 1;
      for (int i: range(0, H - 1)) {
        if (!base[i] && !base[i + 1]) {
          L = i + 2;
        }
      }
      for (int i: revrange(H, N)) {
        if (!base[i] && !base[i - 1]) {
          R = i - 2;
        }
      }
      while (L < N && !base[L]) {
        ++L;
      }
      while (R >= 0 && !base[R]) {
        --R;
      }
      if (L >= R) {
        return false;
      }
      if (L == 0 && R == N - 1) {
        return true;
      }
      std::vector<int> pos;
      {
        int i = L;
        while (i < R) {
          if (base[i] && base[i + 1]) {
            int k = i;
            while (k <= R && base[k]) {
              if (k == H - 1) {
                return true;
              }
              ++k;
            }
            pos.push_back(i);
            pos.push_back(k - 1);
            i = k;
          }
          else {
            ++i;
          }
        }
      }
      if (pos.empty()) {
        return false;
      }
      if ((L + pos.front()) / 2 <= H - 1 && H - 1 <= pos.front()) {
        return true;
      }
      if (pos.back() <= H - 1 && H - 1 <= (pos.back() + R) / 2) {
        return true;
      }
      for (int i: range(0, pos.size() - 1)) {
        if (pos[i] <= H - 1 && H - 1 <= pos[i + 1]) {
          return true;
        }
      }
      return false;
    }() ? ok : ng) = md;
  }
  std::cout << ok << '\n';
  return 0;
}


Measured memory_bytes: 1408
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    auto a = make_vec<int>(n, m);
    rep(i, n) rep(j, m) cin >> a[i][j];
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    rep(i ,n) {
        int res = 0;
        rep(j, m) res += a[i][j] * b[j];
        cout << res << endl;
    }
}



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

namespace mondai0057
{
	class Program
	{
		static void Main(string[] args)
		{
			var	s	= "";
			while( (s = Console.ReadLine()) != null ) {
				var	n	= int.Parse( s );
				var	a	= (n * n + n + 2) / 2;
 				Console.WriteLine( a );
			}
		}
	}
}

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

int main()
{
    string str;
    cin >> str;
    int A = 0;
    int Z = 0;
    
    for(int i = 0; i < str.size(); ++i)
    {
        if(str[i] != 'A')
        {
            ++A;
        }
        else
        {
            break;
        }
    }
    for(int i = str.size()-1; i >= 0 ; --i)
    {
        if(str[i] != 'Z')
        {
            ++Z;
        }
        else
        {
            break;
        }
    }
    int len = str.size() - (A+Z);
    cout << len << endl;
}

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

using namespace std;
const long long MOD = (long long)1e9 + 7;

int main(){
	int n;
    long long ans = 1;
	cin >> n;
    vector<long long> t(n + 2), a(n + 2);
    for(int i = 1; i <= n; i++){
        cin >> t[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        if(t[i - 1] < t[i] && a[i] > a[i + 1]){
            if(t[i] != a[i]){
                ans = 0;
                break;
            }
        }else if(t[i - 1] == t[i] && a[i] == a[i + 1]){
            ans = (ans * min(t[i], a[i])) % MOD;
        }else if(t[i - 1] < t[i] && a[i] == a[i + 1]){
            if(t[i] > a[i]){
                ans = 0;
                break;
            }
        }else{
            if(t[i] < a[i]){
                ans = 0;
                break;
            }
        }
    }
	cout << ans << endl;
	return 0;
}


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  int N, X, T;
  cin >> N >> X >> T;
  int tot = 0;
  int time = 0;
  while (tot < N) {
    time += T;
    tot += X;
  }
  cout << time << endl;

  return 0;
}

Measured memory_bytes: 3628
from functools import reduce
from operator import xor
M, K = map(int, input().split())
if M == 1 and K == 1:
    print(-1)
elif not K:
    print(*(list(range(2**M)) + list(range(2**M))[::-1]))
elif not 0 <= K <= 2**M -1:
    print(-1)
else:
    T = [i for i in range(2**M) if i != K]
    if K != reduce(xor, T):
        print(-1)
    else:
        print(*([K] + T + [K] + T[::-1]))


Measured memory_bytes: 58244
package main

import "fmt"

func solve(s string) int{
    l := 0
    r := len(s)-1
    ans := 0
    for ; l < r;{
        switch{
            case s[l] == s[r]:
            ans += 0
            case s[l] != s[r]:
            ans += 1
        }
        l++
        r--
    }
    return ans
}

func main(){
    var s string
    fmt.Scan(&s)
    fmt.Println(solve(s))
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[100001];
        int d = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if(0 < a[x])d++;
            a[x]++;
        }
        System.out.println(n - d -(d % 2));
        sc.close();

    }

}


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


int main() {
  int N;
  string str;
  cin >> N;
  cin >> str;
 
  int B_count = 0;
  int R_count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == 'B') {
      B_count++;
    }
  }
  for (int j = 0; j < str.size(); j++) {
    if (str.at(j) == 'R') {
      R_count++;
    }
  }
  

  
	if(R_count > B_count){
		cout << "Yes" << endl;
	}
	else if(R_count <= B_count){
		cout << "No" << endl;
	}
 

}
	
	
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
 ll n;
  cin>>n;
  vector<ll> p(n+1);
  rep2(i,1,n+1) cin>>p[i];
  ll count=0;
  rep2(i,1,n){
    if(i==p[i]){
      swap(p[i],p[i+1]);
    count++;
    }
  }
  if(p[n]==n) count++;
  cout<<count<<endl;
return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> A(N);
  double ans=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    A[i]=1.0/A[i];
  }
  ans = 1.0/accumulate( A.begin(), A.end() , 0.0);
  cout << ans << endl;
  return 0;
}

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

int main()
{
    string s,t;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(t.length() != 0 && s[i] == 'B') t.pop_back();
        if(s[i] == '0') t += '0';
        if(s[i] == '1') t += '1';
    }

    cout << t << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <stack>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
typedef vector<int> Ivec;
typedef pair<int, int> pii; // (cst, to)

int main() {
	int n, m;
	map<string, bool> IDs;
	scanf("%d", &n);
	for (int i = 0; n > i; i++) {
		char str[11];
		scanf("%s", str);
		IDs[string(str)] = true;
	}
	scanf("%d", &m);
	bool state = false;
	for (int i = 0; m > i; i++) {
		char str[11];
		scanf("%s", str);
		if (IDs[string(str)]) {
			state = 1 - state;
			printf("%sed by %s\n", state ? "Open" : "Clos", str);
		}
		else {
			printf("Unknown %s\n", str);
		}
	}

	return 0;
}

Measured memory_bytes: 3388