akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int h,w;
  cin>>h>>w;
  int c[10][10];
  rep(i,10)rep(j,10){cin>>c[i][j];}
  vector<int>d(10);
  rep(i,10)d[i]=c[i][1];
  rep(i,10){
    if(i!=1){
      vector<int>v(0);
      rep(j,10){
        if(j!=i)v.push_back(j);
      }

      do{
        int t=0;
        for(int k=0;k<9;k++){
          if(k==0) {
            t+=c[i][v[k]];
            if(v[0]==1)continue;
          }
          if(k!=0){
            t+=c[v[k-1]][v[k]];
            if(v[k]==1){
              d[i]=min(d[i],t);
            }
          }
          if(t>d[i])break;
        }
      }while(next_permutation(v.begin(),v.end()));
    }
  }
  int ans=0;
    rep(i,h){
      rep(j,w){
        int a;
        cin>>a;
        if(a==1||a!=-1){
          ans+=d[a];
        }
      }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main(){
	int a,b,c;
  	cin >> a >> b >> c;
  	int x;
  	cin >> x;
  
  	int count=0;
  	for(int i=0; i<=a; i++){
     	for(int j=0; j <=b; j++){
         	for(int s=0; s<=c; s++){
             	if(x == i*500 + j*100 + s*50) count++;
            }
        }
    }
  
  	cout << count;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main() {
	long int n,k;
	scanf("%ld %ld", &n, &k);
	int h[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	int t = 0;
	for (int i = 0; i < n; i++) {
		if (h[i] >= k) {
			t++;
		}
	}
	printf("%d", t);
	return 0;
}

Measured memory_bytes: 512
import math
import collections

K = int(input())

# intで初期化するため0が返る
cnt = collections.defaultdict(int)
for i in range(1, K + 1):
    for j in range(1, K + 1):
        key = math.gcd(i, j)
        # 最大公約数をkeyにし、同じ最大公約数の出現回数を保持
        cnt[key] = cnt[key] + 1

total = 0
for k in range(1, K + 1):
    for key in cnt.keys():
        # 出現済みの最大公約数との最大公約数を取り、出現回数分を加算する
        total = total + math.gcd(k, key) * cnt[key]

print(total)


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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s;
  cin >> s;
  ll a=0,b=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0')a++;
    else b++;
  }
  cout << 2*min(a,b) << endl;


}

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

using namespace std;
bool done[100010];

void dfs(int v, vector<int>& path, const vector<vector<int> >& G) {
    for (int ch : G[v]) {
        if (done[ch]) continue;
        done[ch] = true;
        path.push_back(ch);
        dfs(ch, path, G);
        return;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int> > G(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b); G[b].push_back(a);
    }
    vector<int> left, right;
    left.push_back(0); done[0] = true;
    right.push_back(G[0][0]); done[G[0][0]] = true;
    dfs(0, left, G);
    dfs(G[0][0], right, G);
    reverse(left.begin(), left.end());
    vector<int> ans;
    for (int el : left) {
        ans.push_back(el);
    }
    for (int el : right) {
        ans.push_back(el);
    }
    cout << ans.size() << endl;
    cout << ans[0]+1 ;
    for (size_t i = 1; i < ans.size(); ++i) {
        cout << " " << ans[i]+1;
    }
    cout << endl;
    return 0;
}

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

#define MAX 200002

char buf[MAX];

string s;
int n;

int dp[1 << 26];

int main() {
	scanf("%s", buf);
	s = buf;
	memset(dp, -1, sizeof(dp));
	int cur = 0;
	dp[0] = 0;
	int las = 0;
	for (int i = 0; i < s.size(); i++) {
		int id = s[i] - 'a';
		cur ^= (1 << id);
		int nex = INT_MAX;
		if (dp[cur] != -1) {
			nex = min(nex, dp[cur]);
		}
		for (int j = 0; j < 26; j++) {
			int go = cur;
			go ^= (1 << j);
			if (dp[go] != -1) {
				nex = min(nex, dp[go]);
			}
		}
		if (nex != INT_MAX) {
			if (dp[cur] == -1 || dp[cur] > nex + 1) {
				dp[cur] = nex + 1;
			}
			las = nex + 1;
		}
	}
	cout << las << endl;
	return 0;
}

Measured memory_bytes: 262912
n = int(input())
a_list = list(map(int,input().split()))
abs_list = []
minus = 0
check = False
for a in a_list:
  abs_list.append(abs(a))
  if a < 0:
    minus += 1
  if a == 0:
    check = True
if minus % 2 == 0 or check == True:
  print(sum(abs_list))
else:
  print(sum(abs_list) - 2 * min(abs_list))

Measured memory_bytes: 65184
#include <cstdint>
#include <iostream>

using namespace std;

int main() {
  int64_t H, N;
  cin >> H >> N;

  for (int64_t n = 0; n < N; ++n) {
    int64_t A;
    cin >> A;
    H -= A;
    if (H <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)


using Graph = vector<vector<int>>;


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


void solve()
{
  ll n, m; cin >> n >> m;
  /*
  vector<ll> a(m);
  vector<ll> b(m);
  */
  Graph G(n);
  REP(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> dist(n, -1);
  queue<int> que;
  vector<int> direct(n, -1);
  // ll ans = 0;
  bool ok = true;
  
  dist[0] = 0;
  que.push(0);
  while(!que.empty()) {
    int v = que.front();
    que.pop();
    for(int nv : G[v]) {
      if(dist[nv] != -1) continue;

      dist[nv] = dist[v] + 1;
      direct[nv] = v;
      que.push(nv);
    }
  }

  for(int i = 1; i < n; i++) {
    if(direct[i] < 0) ok = false;
  }
  if(ok) {
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++) {
      cout << direct[i] + 1 << endl;
    }
  } else {
    cout << "No" << endl;
  }
  // cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 10724
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());

        // 合計値
        List<Integer> total = new ArrayList<Integer>();

        long sum = 0L;

        for (int i =0; i <= n; i++) {
            boolean fizz = i % 3  == 0;
            boolean buzz =  i % 5 == 0;
            if (fizz || buzz)  continue;

            fizz = false;
            buzz = false;
            sum += i;
        }



        System.out.println(sum);
    }
}

Measured memory_bytes: 35756
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	bool flag=true;
	for(int i=n;i<=m;++i)
	{
		if(i<0)
		{
			if(flag)
				flag=false;
			else
				flag=true;
		}
		if(i==0)
		{
			cout<<"Zero"<<endl;
			return 0;
		}
	}
	if(flag)
		cout<<"Positive"<<endl;
	else
		cout<<"Negative"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define MAX 200009
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		int a; cin >> a;
		cout << a + a*a + a*a*a;	
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
int32_t main()
{
	fast;
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	sort(v.begin(), v.end());
	double x=-1;
	for(int i=1;i<n;i++)
	{
		if(i==1)
		{
			x=(v[0]+v[1])/2.0;
		}
		else
		{
			x=(x+v[i])/2.0;
		}
	}
	cout<<fixed<<setprecision(10)<<x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) \
    SORT(a);     \
    reverse(a.begin(), a.end())
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

typedef pair<ll, ll> ii;
typedef vector<ii> vp;
#define OUTA2(a, n) \
    REP(i, n) { cout << (a[i]).first << " " << (a[i]).second << endl; }

ll N;
vi X, L;

int main()
{
    cin >> N;
    X = vi(N);
    L = vi(N);
    REP(i, N)
    {
        cin >> X[i] >> L[i];
    }

    vp A = vp(N);
    REP(i, N)
    {
        A[i] = ii(X[i] + L[i], X[i] - L[i]);
    }
    SORT(A);
    ll prev = -INF;
    ll ans = 0;
    REP(i, N)
    {
        if (prev <= A[i].second)
        {
            ++ans;
            prev = A[i].first;
        }
    }

    OUT(ans);
}

Measured memory_bytes: 3328
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	long X, Y;
	std::cin >> X >> Y;
	if (X % Y == 0)
		std::cout << "-1\n";
	else
		std::cout << X << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    constexpr int maxa = 200010;
    
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(2 * n);
    REP(i, n) {
        cin >> a[i];
        a[i + n] = a[i];
    }
    
    vector<int> s(n, -1), t(maxa, -1);
    REP(i, 2 * n) {
        if (t[a[i]] < n && t[a[i]] != -1) s[t[a[i]]] = i + 1;
        t[a[i]] = i;
    }
    
    int cnt = 0, now = 0;
    while (true) {
        now = s[now];
        while (now >= n) {
            now -= n;
            ++cnt;
        }
        if (!now) break;
    }
    
    k %= cnt;
    if (!k) return 0;
    cnt = 0; now = 0;
    while (true) {
        int now_ = s[now];
        if (cnt + now_ / n < k) {
            now = now_ % n;
            cnt += now_ / n;
        } else {
            break;
        }
    }
    for (int i = now; i < n; ++i) {
        if (s[i] <= n) i = s[i] - 1;
        else cout << a[i] << "\n";
    }
    return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

int main () {
	int a, b;
	cin >> a >> b;
	if (a <= 0 && 0 <= b) puts ("Zero"); else
	if (a > 0) puts ("Positive"); else {
		if ((b-a+1)%2 == 0) puts ("Positive");
		else puts ("Negative");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
#define f first
#define s second
#define CS ios_base::sync_with_stdio(0);cin.tie(0);
#define PI acos(-1)
typedef long long ll;
typedef long double ld;
const int mod = ( int ) 1e9 + 7;
const int mod2 = ( int ) 1e9 + 9;
const ll inf = 1e18 + 100;
const int INF = 2000000000;
const int N = 1e6 + 100;
const long double EPS = 1e-9;
typedef complex < double > pt;

const int MAXLENGTH = 2 * 100 * 1000 + 9;
char str[MAXLENGTH + 1];
int suf[MAXLENGTH + 1];
int group[MAXLENGTH + 1];
int sorGroup[MAXLENGTH + 1];

int groupStart[MAXLENGTH + 1];
int newSuf[MAXLENGTH + 1];
int n;

void buildSuffixArray(){

	n = 0;
	memset ( sorGroup, -1, (sizeof sorGroup[0]) * 128 );

	for( n = 0 ; n - 1 < 0 || str[n - 1] ; n++ )
		newSuf[n] = sorGroup[str[n]], sorGroup[str[n]] = n;

	int numGroup = -1, j = 0;
	for( int i = 0 ; i < 128 ; i++ ){
		if( sorGroup[i] != -1 ){
			groupStart[++numGroup] = j;
			int cur = sorGroup[i];

			while( cur != -1 ){
				suf[j++] = cur;
				group[cur] = numGroup;
				cur = newSuf[cur];
			}
		}
	}

	sorGroup[0] = sorGroup[n - 1] = 0;
	newSuf[0] = suf[0];

	for( int h = 1 ; sorGroup[n - 1] != n - 1 ; h <<= 1 ){
		for( int i = 0 ; i < n ; i++ ){
			int j = suf[i] - h;
			if( j < 0 )
				continue;
			newSuf[groupStart[group[j]]++] = j;
		}
		for( int i = 1 ; i < n ; i++ ){
			bool newgroup = group[newSuf[i - 1]] < group[newSuf[i]] || (group[newSuf[i - 1]] == group[newSuf[i]] &&group[newSuf[i - 1] 						+h]<group[newSuf[i] + h]);

			sorGroup[i] = sorGroup[i - 1] + newgroup;
			if( newgroup )
				groupStart[sorGroup[i]] = i;
		}
		for( int i = 0 ; i < n ; i++ ){
			suf[i] = newSuf[i];
			group[suf[i]] = sorGroup[i];
		}
	}
}

int Rank[MAXLENGTH + 1];
int lcp[MAXLENGTH + 1];

void buildLcp(){
	for( int i = 0 ; i - 1 < 0 || str[i - 1] ; i++ )
		Rank[suf[i]] = i;

	int c = 0;
	for( int i = 0 ; i - 1 < 0 || str[i - 1] ; i++ ){
		if( Rank[i] ){
			int j = suf[Rank[i] - 1];
			while( str[i + c] == str[j + c] )
				c++;
		}
		lcp[Rank[i]] = c;
		if( c )
			c--;
	}
}

int main()
{
	CS;

	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
		str[i] = s[i];
	int k;
	cin >> k;
	buildSuffixArray ();
	buildLcp ();

	int cnt = 0;
	for(int i = 1; i < n; i++)
	{
		int t = s.size () - suf[i] - lcp[i];
		if(cnt + t >= k)
		{
			int len = k - cnt;
			len = lcp[i] + len;
			for(int j = suf[i]; len; j++, len--)
				cout << s[j];
			return 0;
		}
		cnt += t;
	}


	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>

using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
#define eps 1.0e-14;

int main(){
    int A,B;
    cin >> A >> B;
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		String[] strs = str.split("");
		boolean flag = true;

		if(!strs[2].equals(strs[3])) flag = false;
		if(!strs[4].equals(strs[5])) flag = false;

		if (flag) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
mod=10**9+7

N,K=[int(i) for i in input().split(" ")]

nums=[i for i in range(N+1)]

retval=0
min=sum(nums[:K])
max=sum(nums[-K:])

for k in range(K,N+2):
    min=k*(k-1)//2
    max=N*k-min
    retval+=max-min+1
retval=retval%mod
print(retval)


Measured memory_bytes: 18296
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	ll n, m;
	cin >> n >> m;
	ll s = m / 2;
	ll ans = min(n, s);
	m -= (ans * 2);
	m /= 4;
	ans += m;
	f(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const ll MAXN = 8020;

int main()
{
  string s;
  cin >> s;
  int x,y;
  cin >> x >> y;

  vector<int> t;
  int cnt = 0;
//文字列を変形する
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'T'){
      if(cnt != 0) t.push_back(cnt);
      t.push_back(0);
      cnt = 0;
    }else{
      cnt++;
      if(i == s.size()-1) t.push_back(cnt);
    }
  }

  bool dp_x[MAXN][MAXN*2] = {false}, dp_y[MAXN][MAXN*2] = {false};
  dp_x[0][8000] = true;
  dp_y[0][8000] = true;

  bool flag = false;
  bool xy = true; // trueならx軸について見ている
  int cnt_x = 0,cnt_y = 0;

  for(int i = 0; i < t.size(); i++){
    if(t[i] == 0){
      xy  = !xy;
    }else if(xy){
      cnt_x++;
      for(int j = 0; j < MAXN*2; j++){
        if(dp_x[cnt_x-1][j]){
          if(j+t[i] < MAXN*2) dp_x[cnt_x][j+t[i]] = true;
          if(j-t[i] >= 0 && flag) dp_x[cnt_x][j-t[i]] = true;
        }
      }
    }else if(!xy){
      cnt_y++;
      for(int j = 0; j < MAXN*2; j++){
        if(dp_y[cnt_y-1][j]){
          if(j+t[i] < MAXN*2) dp_y[cnt_y][j+t[i]] = true;
          if(j-t[i] >= 0) dp_y[cnt_y][j-t[i]] = true;
        }
      }
    }

    if(!flag) flag = true;
  }

  cout << ((dp_x[cnt_x][x+8000] && dp_y[cnt_y][y+8000]) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 251648
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		
		
		int cal = sc.nextInt();
		int dol = A;
		
		int[] tops = new int[N];
		
		for(int i = 0; i < N; i++){
			tops[i] = sc.nextInt();
		}
		
		Arrays.sort(tops);
		
		for(int i = N - 1; i >= 0; i--){
			if(((double)cal) / dol < ((double)cal + tops[i]) / (dol + B)){
				cal += tops[i];
				dol += B;
			}
		}
		
		System.out.println((int)(cal / dol));
		
	}

}

Measured memory_bytes: 12000
import itertools
n,m,q = (int(x) for x in input().split())
l = []
a = [1,2,3,4,5,6,7,8,9,10]
b = []
c = []
d = []


for i in range(q):
    l.append([])
    l[i]=list(map(int, input().split()))
    
for i in itertools.combinations_with_replacement(a[:m], r=n):#考えられる数列
        b.append(i)        
    
for i in range(len(b)):#それぞれの数列の得点表
    d.append(0)

for i in range(q):
    w=l[i][0]-1#a
    x=l[i][1]-1#b
    y=l[i][2]#c
    z=l[i][3]#d
    for j in range(len(b)):
        if b[j][x]-b[j][w]==y:
            d[j]+=z

print(max(d))


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll modpow(ll n, ll r) {
    ll ret = 1;
    ll p = n;
    while (r > 0) {
        if (r & 1)
            ret = (ret * p) % MOD;
        p = (p * p) % MOD;
        r /= 2;
    }
    return ret;
}

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll N = S.length();

    Combination cmb(N + K + 10);
    ll ans = 0;

    REP(i, N + K) {
        ll p = cmb.get(N + K - i - 1, N - 1) * modpow(25LL, K - i);

        p %= MOD;
        p = (p * modpow(26LL, i)) % MOD;
        ans = (ans + p) % MOD;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 35636
a = int(input())
C = list()
last = [-1] * 2 * 100002
for i in range(a):
    C.append(int(input()))

ans = [1] * a
last[C[0]] = 0
# print(last,ans)
for i in range(1, a):
    ans[i] = ans[i - 1]
    if C[i] == C[i - 1]:
        continue
    if last[C[i]] != -1:
        ans[i] += ans[last[C[i]]]
    last[C[i]] = i

print(ans[a - 1] % 1000000007)

Measured memory_bytes: 762008
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	string S;
	getline(cin, S);

	for (int i = 0; i < S.size(); i++) {
		if (isupper(S[i])) 
			S[i] = tolower(S[i]);
		else if (islower(S[i])) 
			S[i] = toupper(S[i]);
	}

	cout << S << endl;

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(int i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> ls;
  vector<int> rs;

  ls.push_back(0);
  rs.push_back(0);

  int l = 0;
  bool isb = false;
  rep(i, n) {
    if (s[i] == '#') {
      l++;
      isb = true;
    } else if (isb) {
      ls.push_back(l);
      isb = false;
    }
  }

  int r = 0;
  bool isw = false;
  for (int i = n-1; i >= 0; i--) {
    if (s[i] == '.') {
      r++;
      isw = true;
    } else if (isw) {
      rs.push_back(r);
      isw = false;
    }
  }

  rep(i, ls.size()) {
    ls[i] += rs[ls.size()-i-1];
  }

  cout << *min_element(ls.begin(), ls.end()) << endl;

  return 0;
}


Measured memory_bytes: 1780
h, w = map(int, input().split())
inf = 10 ** 9
ans1 = inf
#Hに平行な線を引く
#T字型に分割
div_h = round(h/3)
div_w = w // 2
s = [div_h * w, (h - div_h) * div_w, (h - div_h) * (w - div_w)]
ans11 = max(s) - min(s)

#三型に分割
if w < 3:
    ans12 = inf
else:
    div_h2 = (h - div_h) // 2
    s = [div_h * w, div_h2 * w, (h - div_h - div_h2) * w]
    ans12 = max(s) - min(s)
#Wに平行
div_w = round(w/3)
div_h = h // 2
s = [div_w * h, (w - div_w) * div_h, (w - div_w) * (h - div_h)]
ans21 = max(s) - min(s)

#三型に分割
if h < 3:
    ans22 = inf
else:
    div_w2 = (w - div_w) // 2
    s = [div_w * h, div_w2 * h, (w - div_w - div_w2) * h]
    ans22 = max(s) - min(s)
print(min(ans11, ans12, ans21, ans22))

Measured memory_bytes: 3064
N=int(input())
d={}
ans=0
for n in range(N):
    S=input()
    if S in d:
        d[S]+=1
    else:
        d[S]=1
M=int(input())
for m in range(M):
    T=input()
    if T in d:
        d[T]-=1
    else:
        d[T]=1
for k in d:
    if d[k]>ans:
        ans=d[k]
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	string s;
	cin>>s;
	REP(i,0,s.length()-1){
		if(i%2==0)cout<<s[i];
	}
	return 0;

//   TimeTaken();
}


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

void solve()
{
    string s;
    cin >> s;
    rep(bit, 1 << 3)
    {
        int tmp = s[0] - '0';
        string ans;
        ans += s[0];
        rep(i, 3)
        {
            if (bit & (1 << i))
            {
                tmp += s[i + 1] - '0';
                ans += "+";
                ans += s[i + 1];
            }
            else
            {
                tmp -= s[i + 1] - '0';
                ans += "-";
                ans += s[i + 1];
            }
        }
        if (tmp == 7)
        {
            printf("%s=7\n", ans.c_str());
            return;
        }
    }
}

int main()
{
    solve();
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    string s;
    cin >> s;
    char c = s[0];
    for(int i = 1; i < s.size(); ++i){
        if(s[i] == c) {
            ppp("Bad");
            return 0;
        }
        c = s[i];
    }
    ppp("Good");

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

char s[2000][2001];
int sum[2001][2001];
int sum2[2001][2001];
int sum3[2001][2001];

int main() {
    int n, m, q, i, j;
    
    scanf("%d %d %d", &n, &m, &q);
    
    for (i = 0; i < n; i++) scanf("%s", s[i]);
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
            if (s[i][j] == '1') sum[i + 1][j + 1]++;
            
            sum2[i + 1][j + 1] = sum2[i + 1][j] + sum2[i][j + 1] - sum2[i][j];
            if (i + 1 < n && s[i][j] == '1' && s[i + 1][j] == '1') sum2[i + 1][j + 1]++;
            
            sum3[i + 1][j + 1] = sum3[i + 1][j] + sum3[i][j + 1] - sum3[i][j];
            if (j + 1 < m && s[i][j] == '1' && s[i][j + 1] == '1') sum3[i + 1][j + 1]++;
        }
    }
    
    for (i = 0; i < q; i++) {
        int x1, y1, x2, y2, ans = 0;
        
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        
        x1--;
        y1--;
        
        ans += sum[x2][y2] - sum[x2][y1] - sum[x1][y2] + sum[x1][y1];
        ans -= sum2[x2 - 1][y2] - sum2[x2 - 1][y1] - sum2[x1][y2] + sum2[x1][y1];
        ans -= sum3[x2][y2 - 1] - sum3[x2][y1] - sum3[x1][y2 - 1] + sum3[x1][y1];
        
        printf("%d\n", ans);
    }
    
    return 0;
}


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

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

  //絶対に重ならない場合
  if(b <= c || d <= a)
  {
    cout << 0 << endl ;
    return 0 ;
  }

  int calcu = max(b, d) - min(a, c) ;
  cout << calcu - (max(a, c) - min(a, c)) - (max(b, d) - min(b, d)) << endl ;
}


Measured memory_bytes: 256
#include <stdio.h>

int n,m;
int a[110];
int main(){
	scanf("%d%d",&n,&m);
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		sum+=a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++)if(a[i]*4*m>=sum)ans++;
	puts(ans>=m?"Yes":"No");
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long ima = sc.nextLong();
    long ans = 0;
    for(int i = 1; i < n; i++) {
      long x = sc.nextLong();
      long t = a * (x - ima);
      if(t > b) {
        ans += b;
      } else {
        ans += t;
      }
      ima = x;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 48212
#include<bits/stdc++.h>
using namespace std;
const int N=10005,inf=1e9+7;
int n,s1,s2,ans;
char s[N],t[N];
vector<int>a,b;
void sol(vector<int>&V,char *s){for(int i=1;i<n;i++)if(s[i]!=s[i+1])V.push_back(i);}
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	sol(a,s);s1=a.size();
	sol(b,t);s2=b.size();
	ans=inf;
	for(int d=-s1-1;d<=s2+1;d++)if((d+(s[1]==t[1]))&1)
	{
		int r=0;
		for(int i=min(-d,0);i<max(s1,s2-d);i++)
		{
			int j=i+d,px,py;
			px=i<0?0:(i>=s1?n:a[i]);
			py=j<0?0:(j>=s2?n:b[j]);
			r+=abs(px-py);
		}
		ans=min(ans,r);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;

void reverse(string x, int y, int z) {
	int left = y, right = z;
	while (left < right) {
		swap(x[left++], x[right--]);
	}
}

int main() {

	string a;//最初の文字列
	int b;//命令の数
	string c;//命令
	int c1;
	int c2;//命令の数字
	string c3;

	cin >> a;
	cin >> b;

	for (int i = 0; i < b; i++) {
		cin >> c >> c1 >> c2;
		if (c == "print") {
			cout << a.substr(c1, c2 - c1 + 1) << endl;
		}
		if (c == "replace") {
			cin >> c3;
			a.replace(c1, c2 - c1 + 1, c3);
		}
		if (c == "reverse") {
			reverse(a.begin() + c1, a.begin() + c2 + 1);
		}
	}

	return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
#include<string.h>
int main(){
  char str[250],ans[250],tmp[10][10]={"abcde","fghij","klmno","pqrst","uvwxy","z.?! "};
  int i,flg,l,a,cnt;
  
  while(scanf("%s",str)!=EOF){
    for(i=0;i<240;i++)ans[i]=0;
    l=strlen(str);
    if(l%2==1){
    exit:
      printf("NA\n");
    }
    else {
      for(cnt=0,i=0;i<l;i+=2,cnt++){
	if(!(str[i]>='1'&&str[i]<='6'&&str[i+1]>='1'&&str[i+1]<='5'))goto exit;
	ans[cnt]=tmp[(str[i]-'0'-1)][(str[i+1]-'0'-1)];
      }
      str[cnt]='\0';
      printf("%s\n",ans);
    }

  }
  return 0;
}

Measured memory_bytes: 524
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "3 5\n.....\n.#.#.\n.....\n" => "11211\n1#2#1\n11211\n",
    "3 5\n#####\n#####\n#####\n" => "#####\n#####\n#####\n",
    "6 6\n#####.\n#.#.##\n####.#\n.#..#.\n#.##..\n#.#...\n" => "#####3\n#8#7##\n####5#\n4#65#2\n#5##21\n#4#310\n",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        h: isize,
        w: isize,
        v: [chars; h],
    };

    let mut v = v;

    let dy = [-1, -1, -1, 0, 0,  1, 1, 1];
    let dx = [-1, 0, 1, -1, 1, -1, 0, 1];

    for i in 0..h {
        for j in 0..w {
            if v[i as usize][j as usize] == '#' {
                continue;
            }

            let mut count = 0;

            for d in 0..8 {
                let ni = i + dy[d];
                let nj = j + dx[d];

                if ni < 0 || h <= ni {
                    continue;
                }
                
                if nj < 0 || w <= nj {
                    continue
                };

                if v[ni as usize][nj as usize] == '#' {
                    count += 1;
                }
            }

            v[i as usize][j as usize] = std::char::from_digit(count as u32, 10).unwrap();
        }
    }

    let mut ans = String::new();
    for i in 0..h {
        let s = format!("{}\n",v[i as usize].iter().cloned().collect::<String>());
        ans.push_str(&s);
    }

    ans
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, a, n) for ( i = a; i < (n); i++)
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define x first
#define y second
#define mp make_pair
#define pb push_back
using namespace std;

int main(){
	fast;
	ll i,j,W,k,tc,q,n,flag;	
	cin>>n>>W;
	vector <ll> w(n),v(n);
	rep(i,0,n)
		cin >> w[i] >> v[i] ;

	ll dp[n+1][W+1]={0};
	rep(i,0,n+1){
		rep(j,0,W+1){
			if(i==0	||j==0){
				dp[i][j]=0;

			}
			else if(w[i-1]<=j){
				dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
			}
			else dp[i][j]=dp[i-1][j];
			
		}
	}
	cout<<dp[n][W]<<endl;
	// rep(i,0,n+1){
	// 	rep(j,0,W+1){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	return 0;
}


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

using namespace std;

typedef long long ll;


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

	if(a % x == 0)
		cout << b/x - a/x + 1<< endl;
	else
		cout << b/x - a/x << endl;


	return 0;
}



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

int main() {
  // Aマスを白色に塗る時、黒色に塗ることになるマスの個数を出力する。
	int N, A;
	cin >> N >> A;
  
  	// N = 3, A = 4;
  
  	cout << N * N - A << endl;
}
  

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,c;
    cin >> n >> c;
    vector<vector<int>> d(c,vector<int>(c));
    vector<vector<int>> b(n,vector<int>(n));
    REP(i,c){
        REP(j,c){
            cin >> d[i][j];
        }
    }
    REP(i,n){
        REP(j,n){
            cin >> b[i][j];
            b[i][j]--;
        }
    }
    vector<vector<int>> s(3,vector<int>(c,0));
    REP(i,n){
        REP(j,n){
            s[(i+j)%3][b[i][j]]++;
        }
    }
    vector<int> com (c,0);
    REP(i,3)com[i]=1;
    reverse(all(com));
    int res = INT_MAX;
    REP(i,c){
        REP(j,c){
            REP(k,c){
                if(i!=j&&j!=k&&k!=i){
                    int temp = 0;
                    REP(m,c){
                        temp+=d[m][i]*s[0][m];
                        temp+=d[m][j]*s[1][m];
                        temp+=d[m][k]*s[2][m];
                        
                    }
                    chmin(res,temp);
                }
            }
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
   int a,b;
   scanf("%d%d",&a,&b);
   if (b%a==0)
   {
       printf("%d",a+b);
       return 0;
   }
   printf("%d",b-a);
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define res register int
#define N 5000
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int head[N],n,m,k,tot,tot1,ans;
struct data{
    int to,nxt;
}edge[N];

inline void add(int x,int y)
{
    edge[++tot1].to=y;
    edge[tot1].nxt=head[x];
    head[x]=tot1;
}


inline void dfs(int root,int fa,int deth)
{
    if (deth>k/2)
    tot++;
    for(res i=head[root];i;i=edge[i].nxt)
    {
        int y=edge[i].to;
        if(fa==y) continue;
        dfs(y,root,deth+1);
    }
}

int main()
{
    scanf("%d%d",&n,&k);
    int x,y,z;
    for(res i=1;i<=n-1;i++)
    {
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
    }
    
    ans=inf;
    
    if(k&1)
    {
        for(res i=1;i<=n;i++)
          for(res j=head[i];j;j=edge[j].nxt)
          {
          	int y=edge[j].to;
          	tot=0;
          	dfs(i,y,0);
          	dfs(y,i,0);
          	ans=min(ans,tot);
          }
    }
    
    else
    
    {
        for(res i=1;i<=n;i++)
        {
            tot=0;
            dfs(i,0,0);
            ans=min(ans,tot);
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 384