akhauriyash/Code-Regression huggingface dataset:
//繝・Φ繝励Ξ
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
//


string S;
int x;
int y;

bool dp[8010][16010];
vector<int> dis_x;
vector<int> dis_y;

bool dpdp(vector<int> dis,int value)
{
   REP(i,8010)REP(j,16010) dp[i][j] = false;
   dp[0][8000] = true;
   int N = dis.size();
   REP(i,N)
   {
      REP(j,16000)
      {
         if(j-dis[i] >= 0)
         {
            dp[i+1][j] |= dp[i][j-dis[i]];
         }
         if(j+dis[i] <= 16000)
         {
            dp[i+1][j] |= dp[i][j+dis[i]];
         }
         
      }
   }
   return dp[N][value +8000];
}

signed main (){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   cin >> S;
   cin >> x >> y;
   int i = 0;
   int mode = true;
   int cnt = 0;
   REP(i,S.size()) 
   {
      if(S[i] == 'F') 
      {
         cnt ++;
      }
      else
      {
         (mode ? dis_x :dis_y).push_back(cnt) ;
         mode = !mode;
         cnt = 0;
      }
   }
   (mode ? dis_x :dis_y).push_back(cnt) ;
   int ini_x = 0;
   if(S[0] = 'F')
   {
      ini_x = dis_x[0];
      dis_x[0] = 0;
   }

   bool ok = dpdp(dis_x,x-ini_x) && dpdp(dis_y,y);
   cout << (ok ? "Yes" : "No") << endl;
   

}

//驛ｨ蛻・・譛蟆丞､
//譖ｴ譁ｰ縺励↑縺・ｴ蜷遺・邏ｯ遨阪ｏ
//莠梧ｬ｡蜈・↓縺励◆縺・・縺・ｂ縺呎ｳ・
//荳邂・園繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Segment Tree(縺溘□縺怜叙蠕涌(logN))
//遽・峇繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Lazy Segment Tree


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> m(n);
    vector<int> vec;
    for (int i = 0; i < n; i++) {
        cin >> m.at(i);
    }
    sort(m.begin(), m.end(), greater<>());
    int64_t sum = 0;
    for (int i = k; i < n; i++) {
        sum += m.at(i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 4056
S = input()
keta = len(S)

chk = True
for i in range(keta-1):
    if S[i+1] != '9':
        chk = False
        break

if chk:
    ans = 9 * (keta-1) + int(S[0])
else:
    ans = 9 * (keta-1) + int(S[0]) - 1

print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  
  int answer = 0;
  for(int i=1; i<n-1; i++) {
    vector<int> b(3);
    b[0] = a[i-1];
    b[1] = a[i];
    b[2] = a[i+1];
    
    sort(b.begin(), b.end());
    
    if (b[1] == a[i]) {
      answer += 1;
    }
  }
  
  cout << answer;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 1000005;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int N, Fac[MN], iFac[MN], Ans;

int main() {
	scanf("%d", &N), Fac[0] = 1;
	for (int i = 1; i <= N; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[N] = qPow(Fac[N], Mod - 2);
	for (int i = N; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
	for (int i = 1; i <= N; ++i) Ans = (Ans + (LL)Fac[N] * iFac[i] % Mod * iFac[N - i] % Mod * iFac[i] % Mod * Fac[i - 1] % Mod * (qPow(2, i) + (i & 1 ? 1 : -1))) % Mod;
	printf("%lld\n", (LL)Ans * qPow(3, Mod - N - 2) % Mod * iFac[N] % Mod * Fac[N - 1] % Mod);
	return 0;
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

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

    int ma = -1, mi = INF;
    rep(i, n) {
        int a;
        cin >> a;
        cmax(ma, a);
        cmin(mi, a);
    }

    cout << ma - mi << endl;

}

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

int main(){
    int input;
    cin >> input;
    int hour,min,sec;
    hour = input / 3600;
    min = (input - hour * 3600) / 60;
    sec = input - hour * 3600 - min * 60;
    cout << hour << ":" << min << ":" << sec << "\n";
}


Measured memory_bytes: 3088
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	length := len(n)
	if n[length-1] == '3' {
		fmt.Println("bon")
	} else if n[length-1] == '0' || n[length-1] == '1' || n[length-1] == '6' || n[length-1] == '8' {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
int main(){
    int c_a=0,c_b=0;
    char a='0',b='1';
    string s;
    cin>>s;
    for(char c:s){
        if(c!=a) c_a++;
        else c_b++;
        if(a=='1'){
            a--;
            b++;
        }else{
            a++;
            b--;
        }
    }
    cout<<(c_a<c_b?c_a:c_b)<<"\n";
}

Measured memory_bytes: 512
n = int(input())
st = set()
s = []
ok = True
for i in range(n):
  s.append(input())
for i in range(n):
  if s[i] in st:
    ok = False
  if i > 0 and s[i][0] != s[i-1][-1]:
    ok = False
  st.add(s[i])
print("Yes" if ok else "No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

#define MAX_N 200100
#define pb push_back
vector<int> g[MAX_N];//tree
int N, root = 0, parent[MAX_N], depth[MAX_N];
void dfs(int v, int p, int d)
//v...current vertex , p...parent of v ,d...depth of v
{
	depth[v] = d;
	for (int i = 0; i < g[v].size(); i++)
	{
		if (g[v][i] == p)continue;
		dfs(g[v][i], v, d + 1);
	}
}
void add_edge(int u, int v)
{
	g[u].pb(v);
	g[v].pb(u);
}






int main()
{
	int ax=0,memo;
	scanf("%d", &N);//number of vertexes
	for (int i = 0; i < N -1; i++)// edges
	{
		int u, v;
		scanf("%d %d", &u, &v);
		u--;
		v--;
		add_edge(u, v);
	}
	dfs(root, -1, 0);
	for (int i = 0; i < N; i++)
	{
		if (ax <= depth[i]) {
			memo = i;
		}
		ax = max(ax, depth[i]);
	}

	dfs(memo, -1, 0);
	ax = 0;
	for (int i = 0; i < N; i++)
	{
		if (ax <= depth[i]) {
			memo = i;
		}
		ax = max(ax, depth[i]);
	}
	ax++;
	if (ax % 3 == 2) {
		cout << "Second";
	}
	else {
		cout << "First";
	}
}




Measured memory_bytes: 24448
#include<bits/stdc++.h>
#define ll long long 
#define m 1000000007
using namespace std;
ll dp[101][100001];
ll dp1[101][100001];
ll umin(ll a,ll b)
{
  if(a<b)
    return a;return b;
}
int main(int argc, char const *argv[])
{
  ll n,k;cin >> n >> k;
  ll a[n];ll b[n];
  for(ll i=0;i<n;i++)cin >> a[i];
    for(ll i=0;i<=n;i++)
    {
      for(ll j=0;j<=k;j++)
      {
        if(i==0 and j==0)
        {
          dp[i][j]=1;
          dp1[i][j]=1;
        }
        else
        if(i==0)
        {
          dp[i][j]=0;
          dp1[i][j]=dp1[i][j-1]+dp[i][j];
          dp1[i][j]%=m;
        }
        else if(j==0)
        {
          dp1[i][j]=dp[i][j]=1; 
        }
        else
        {
          if(j>a[i-1])
          dp[i][j]=(dp1[i-1][j]-dp1[i-1][j-a[i-1]-1]+m)%m;
        else
          dp[i][j]=(dp1[i-1][j])%m;
          dp1[i][j]=dp1[i][j-1]+dp[i][j];
          dp1[i][j]%=m;
        }
      }

    }
    /*for(ll i=0;i<=n;i++)
    {
      for(ll j=0;j<=k;j++)
        cout << dp[i][j] << " ";
      cout << "\n";
    }*/

cout << dp[n][k];
  return 0;
}

Measured memory_bytes: 158080
/*{{{*/
#include<bits/stdc++.h>
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 0; I < (N); ++I)
#define repp(I, A, B) for (int I = (A); I <= (B); ++I)
#define repr(I, N) for (int I = (N)-1; I >= 0; --I)
#define reppr(I, A, B) for (int I = (A); I >= (B); --I)
#define fors(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define mp make_pair
#define pb emplace_back
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
/*}}}*/
void solve() {
	string s, ans;
	R(s);
	int n = sz(s);
	rep(i, n)
	ans += 'x';
	W(ans);
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


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

int main(){
  ll a;cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3620
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
if n % 2 == 0:
    if ls[::2] == ls[1::2] and ls[::2] == [e for e in range(n) if e % 2 != 0]:
        print(2**(int(n/2))%(10**9+7))
    else:
        print(0)
else:
    if ls[1::2] == ls[2::2] and ls[::2] ==  [e for e in range(n) if e % 2 == 0]:
        print(2**(int(n/2))%(10**9+7))
    else:
        print(0)

Measured memory_bytes: 88112
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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

  ll N, M, K;
  cin >> N >> M >> K;
  rep(i,N+1){
    rep(j,M+1){
      ll ret = i*j + (N-i)*(M-j);
      if((N*M-ret) == K){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }

  cout << "No" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
ans = 0

for i in range(2 ** (n - 1)):
    k = 0
    num_list = []
    for j in range(n):
        if (i >> j) & 1:
            num = s[k : j + 1]
#             print(num)
            k = j + 1
            num_list.append(int(num))
#             print(num_list)
    num = s[k : n +1]
    num_list.append(int(num))
    ans += sum(num_list)
print(ans)

Measured memory_bytes: 9184
#include<iostream>
#include<math.h>
//#include<vector>                                                                                                     
#include<map>
using namespace std;

int main()
{
  // 整数の入力                                                                                                        
  int N;
  cin >> N;

  map<int, int> number; //key=登校時居た人数、value=出席番号                                         
  int temp;

  for(int i=0; i<N; i++){
    cin >> temp;
    number[temp] = i + 1;
  }

  //出力                                                                                                   
  //key値でソートされているので、valueを順に出力                                                       
  for(auto itr = number.begin(); itr != number.end(); ++itr){
    cout << itr->second << " ";
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 5504
while True:
    ans = []
    h, w = map(int, input().split())
    if h >= 3 and w >= 3:
        for i in range(h):
            if i == 0 or i == h - 1:
                ans.append(['#'] * w)
            else:
                ans.append(['.'] * w)
                ans[i][0] = '#'
                ans[i][w - 1] = '#'
            ans[i] = ''.join(ans[i])
        print('\n'.join(ans) + '\n')
    elif h == 0 and w == 0:
        break


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> R(H, vector<char>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++){
      cin >> R.at(i).at(j);
    } 
  }
  
  vector<int> Hcomp(H), Wcomp(W);
  
  // compress H
    
  for (int i = 0; i < H; i++){
  	bool flag = true;   
    for (int j = 0; j < W; j++){
      if(R.at(i).at(j) == '#'){
        flag = false;
      }
    }
    if (flag){
      Hcomp.at(i) = 1;
    }
  }

  // compress W
    
  for (int i = 0; i < W; i++){
  	bool flag = true;   
    for (int j = 0; j < H; j++){
      if(R.at(j).at(i) == '#'){
        flag = false;
      }
    }
    if (flag){
      Wcomp.at(i) = 1;
    }
  }
  
  // output
  
  for (int i = 0; i < H; i++){
    if(Hcomp.at(i) == 0){
      for (int j = 0; j < W; j++){
      	if(Wcomp.at(j) == 0){
      	  cout << R.at(i).at(j);   
        }
      }
      cout << endl;
    }
  }
}



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

int main(){
    int R, C, K;
    std::cin >> R >> C >> K;
    std::vector< std::vector< int > > RCV(R, std::vector< int >(C, 0));
    for(int i=0; i<K; i++){
        int tmpr, tmpc, tmpv;
        std::cin >> tmpr >> tmpc >> tmpv;
        RCV[tmpr-1][tmpc-1] = tmpv;
    }
    
    std::vector< std::vector< std::vector< long long > > > dp(R+1, std::vector< std::vector< long long > >(C+1, std::vector< long long >(4, 0)));
    
    for(int i=1; i<=R; i++){
        for(int j=1; j<=C; j++){
            for(int k=0; k<4; k++){
                if(k == 0){
                    dp[i][j][k] = std::max(dp[i-1][j][3], dp[i][j-1][k]);
                }else if(k == 1){
                    dp[i][j][k] = std::max(dp[i-1][j][3] + RCV[i-1][j-1], dp[i][j-1][k]);
                    dp[i][j][k] = std::max(dp[i][j-1][0] + RCV[i-1][j-1], dp[i][j][k]);
                }else{
                    dp[i][j][k] = std::max(dp[i][j-1][k-1] + RCV[i-1][j-1], dp[i][j-1][k]);
                    dp[i][j][k] = std::max(dp[i][j][k], dp[i][j][k-1]);
                }
            }
        }
    }
    
    std::cout << dp[R][C][3] << std::endl;
    
    
    return 0;
    
}


Measured memory_bytes: 671296
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

static unsigned int x=123456789;
static unsigned int y=362436069;
static unsigned int z=521288629;
static unsigned int w=88675123;

void seed(unsigned int a,unsigned int b,unsigned int c,unsigned int d) {
	if((a|b|c|d)==0)return;
	x=a;y=b;z=c;w=d;
}

unsigned int randint(void) {
	unsigned int t;
	t=(x^(x<<11));
	x=y;y=z;z=w;
	w=(w^(w>>19))^(t^(t>>8));
	return w;
}

#define HEIGHT 10
#define WIDTH 10

#define SENRYOU_HEIGHT 5
#define SENRYOU_WIDTH 5

const int senryou_num[3] = {5, 9, 13};
const int senryou_data[13][2] = {
	{0, 0}, {0, -1}, {0, 1}, {1, 0}, {-1, 0},
	{-1, -1}, {1, -1}, {-1, 1}, {1, 1},
	{0, 2}, {0, -2}, {-2, 0}, {2, 0}
};

int n;
int kosa[HEIGHT + 2][WIDTH + 2];

#define CANDIDATE_NUM 100

int status[HEIGHT + 2][WIDTH + 2];
int senryou[CANDIDATE_NUM][12][3];

void hanei(int senryou_id, int y, int x) {
	int i;
	for (i = 0; i < senryou_num[senryou_id]; i++) {
		status[y + senryou_data[i][0]][x + senryou_data[i][1]]++;
	}
}

int evaluate(int idx) {
	int i, j;
	int score = 0;
	memset(status, 0, sizeof(status));
	for (i = 0; i < n; i++) {
		hanei(senryou[idx][i][2], senryou[idx][i][1], senryou[idx][i][0]);
	}
	for (i = 0; i < HEIGHT + 2; i++) {
		for (j = 0; j < WIDTH + 2; j++) {
			score += abs(status[i][j] - kosa[i][j]);
		}
	}
	return score;
}

int main(void) {
	int i, y, x;
	int no_sinchoku = 0;
	if (scanf("%d", &n) != 1) return 1;
	for (y = 1; y <= HEIGHT; y++) {
		for (x = 1; x <= WIDTH; x++) {
			if (scanf("%d", &kosa[y][x]) != 1) return 1;
		}
	}
	for (i = 0; i < n; i++) {
		senryou[0][i][0] = randint() % (WIDTH - 2) + 2;
		senryou[0][i][1] = randint() % (HEIGHT - 2) + 2;
		senryou[0][i][2] = randint() % 3;
	}
	for(;;) {
		int maxscore = evaluate(0), maxindex = 0, curscore;
		for (i = 1; i < CANDIDATE_NUM; i++) {
			int idx, which;
			memcpy(senryou[i], senryou[0], sizeof(*senryou));
			idx = randint() % n;
			which = randint() % 8;
			if (which & 1) senryou[i][idx][0] = randint() % (WIDTH - 2) + 2;
			if (which & 2) senryou[i][idx][1] = randint() % (HEIGHT - 2) + 2;
			if (which & 4) senryou[i][idx][2] = randint() % 3;
			curscore = evaluate(i);
			if (curscore < maxscore) {
				maxscore = curscore;
				maxindex = i;
			}
		}
		if (maxscore < evaluate(0)) {
			memcpy(senryou[0], senryou[maxindex], sizeof(*senryou));
			no_sinchoku = 0;
		} else {
			no_sinchoku++;
			if (no_sinchoku >= 10) memcpy(senryou[0], senryou[randint() % (CANDIDATE_NUM - 1) + 1], sizeof(*senryou));
		}
		if (maxscore == 0) break;
	}	
	for (i = 0; i < n; i++) {
		printf("%d %d %d\n", senryou[0][i][0] - 1, senryou[0][i][1] - 1, senryou[0][i][2] + 1);
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000009;
const double pi = acos(-1);

int main() {
    int N;
    cin >> N;
    vecl A(N);
    REP(i,N) cin >> A[i];
    ll ans = 0;
    REP(i,N-1) {
        if(A[i+1] < A[i]) {
            ans += A[i]-A[i+1];
            A[i+1] = A[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n, w;
    cin >> n >> w;
    vector<int> vs(n), ws(n);
    for (int i = 0; i < n; ++i) {
        cin >> vs[i] >> ws[i];
    }
    vector<int> dp(w + 1);
    dp[0] = 0;
    for (int wi = 1; wi <= w; ++wi) {
        for (int i = 0; i < n; ++i) {
            if (ws[i] <= wi) dp[wi] = max(dp[wi], dp[wi - ws[i]] + vs[i]);
        }
    }
    cout << dp[w] << endl;
    return 0;
}



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

int main(){
  int t[4]={6000,4000,3000,2000};
  int a,b;
  int c[4];

  for(int i=0;i<4;i++){
    cin>> a>> b;
    c[i]=b*t[a-1];
  }

  for(int i=0;i<4;i++){
    cout<< c[i]<< endl;
  }
}

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

int calc_digit(long long N) {
    int res = 0;
    while (N) {
        ++res;
        N /= 10;
    }
    return res;
}

int main() {
    long long N;
    cin >> N;
    int res = (1<<29); // 十分大きい値で初期化
    for (long long A = 1; A * A <= N; ++A) {
        if (N % A == 0) {
            long long B = N / A;
            int F = max(calc_digit(A), calc_digit(B));
            res = min(res, F);
        }
    }
    cout << res << endl;
}


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

using namespace std;

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

typedef pair<int, int> pii;
typedef vector<pii> vp;

int n, m;
vector<vp> g; //pos, cost

int dijkstra(int from, int to) {
	priority_queue<pii, vector<pii>, greater<pii> > que; //cost, pos
	vector<int> d(n, INF);
	
	que.push(pii(0, from));
	d[from] = 0;
	while (! que.empty()) {
		int cost = que.top().first;
		int pos = que.top().second;
		que.pop();
		
		if (d[pos] < cost) continue;
		
		REP(i, g[pos].size()) {
			pii now = g[pos][i];
			if (d[now.first] > d[pos] + now.second) {
				d[now.first] = d[pos] + now.second;
				que.push(pii(d[now.first], now.first));
			}
		}
	}
	
	return d[to];
}

int main() {	
	cin >> n >> m;
	g.resize(m);
	REP(i, m) {
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		a--; b--;
		g[a].push_back(pii(b, c));
		g[b].push_back(pii(a, d));
	}
	
	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	x1--; x2--;
	
	int ans = y1 - y2 - (dijkstra(x1, x2) + dijkstra(x2, x1));
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define ll long long
#define br cout << "\n" ;
#define all(x) (x).begin() ,(x).end()
#define rall(x) (x).rbegin() ,(x).rend()
#define pb push_back
#define ff first
#define ss second 
const int MOD = 1000* 1000 * 1000 + 7;
const int MAXN = 1000*1000 + 10 ; 
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
 int n ;
cin >> n ;
ll s = 0 ; 
for(ll i = 1 ; i <= n ; ++i  ){
	
	if ( i % 3 == 0 or i % 5 ==0 or i %15 == 0)
	continue ;
	s += i ; 
} 

cout << s ; 


return 0 ; 
}	


Measured memory_bytes: 3652
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		int k = scanner.nextInt();
		int n = scanner.nextInt();
//		List<Integer> a = new ArrayList<Integer>();
//		Map<Integer, Integer> distMap = new HashMap<Integer, Integer>();
//		for(int i = 1; i <= n; i++){
//			a.add(scanner.nextInt());
//			if(i > 1){
//				distMap.put(i, a.get(i-1)-a.get(i-2));
//			}
//			if(i == n){
//				distMap.put(1, k-a.get(i-1)+a.get(0));
//			}
//		}
		int [] a = new int[n];
		int[] dist = new int[n];
		Map<Integer, Integer> distMap = new HashMap<Integer, Integer>();
		for(int i = 0 ; i < n; i++){
			a[i] = scanner.nextInt();
			if(i > 0){
				dist[i] = a[i] - a[i-1];
				distMap.put(dist[i], i);
			}
			if(i == n-1){
				dist[0] = k - a[i] + a[0];
				distMap.put(dist[0], 0);
			}
		}
		Arrays.sort(dist);
		int result =  k - (dist[n-1]);
		System.out.println(result);
//		System.out.println(Math.abs(maxDistNum));


		scanner.close();
	}

}


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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    i32 S=read(),W=read();
    if(S>W) print("safe");
    else print("unsafe");
    output();
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int n,ac=0,wa=0,tle=0,re=0;
    cin>>n;
    while(n--){     
        cin>>s;  
        if(s=="AC")ac++; 
        else if(s=="WA")wa++; 
        else if(s=="TLE")tle++;
        else if(s=="RE")re++; 
    } 
    cout<<"AC x "<<ac<<"\n"; 
    cout<<"WA x "<<wa<<"\n"; 
    cout<<"TLE x "<<tle<<"\n"; 
    cout<<"RE x "<<re<<"\n";
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const ll MOD_CONST = 1000000007;
 
 
 
int main()
{
	int n, m;
	cin >> n >> m;
 
	vector<vector<ll>> cake(n, vector<ll>(3));
	
	for (int i = 0; i < n; i++) {
		cin >> cake[i][0] >> cake[i][1] >> cake[i][2];
	}
 
	
	ll ans = 0;
	for (int b = 0; b < (1 << 3); b++) {
		priority_queue<vector<ll>>pq;
 
		for (int i = 0; i < n; i++) {
			ll val = 0;
			for (int j = 0; j < 3; j++) {
				val += (((b >> j) & 1) == 1 ? 1 : -1)* cake[i][j];
			}
 
			pq.push(vector<ll>{val, cake[i][0] ,cake[i][1] ,cake[i][2]});
			 
		}
 
 
		ll sumX = 0;
		ll sumY = 0;
		ll sumZ = 0;
		for (int i = 0; i < m; i++) {
			sumX += pq.top()[1];
			sumY += pq.top()[2];
			sumZ += pq.top()[3];
			pq.pop();
 
 
		}
 
		ans = max(ans, abs(sumX) + abs(sumY) + abs(sumZ));
	}
 
	cout << ans << endl;
} 

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

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

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut p: Vec<usize> = Vec::with_capacity(n);
    let mut q: Vec<usize> = Vec::with_capacity(n);

    for _ in 0..n {
        p.push(iterator.next().unwrap().parse().unwrap());
    }
    for _ in 0..n {
        q.push(iterator.next().unwrap().parse().unwrap());
    }

    let perms: Vec<Vec<usize>> = make(n);

    let a: usize = perms.binary_search(&p).unwrap();
    let b: usize = perms.binary_search(&q).unwrap();

    return if a > b {
        format!("{}", a - b)
    } else {
        format!("{}", b - a)
    }
}

fn make(n: usize) -> Vec<Vec<usize>> {
    let mut original = Vec::new();
    for i in 1..(n + 1) {
        original.push(i)
    }

    let mut result = Vec::new();
    _make(original, Vec::new(), &mut result);
    return result;
}

fn _make(candidate: Vec<usize>, perm: Vec<usize>, result: &mut Vec<Vec<usize>>) {
    if candidate.is_empty() {
        result.push(perm);
        return;
    }

    for i in 0..candidate.len() {
        let mut c = candidate.clone();
        let mut p = perm.clone();
        p.push(c.remove(i));
        _make(c, p, result);
    }
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"3
1 3 2
3 1 2"
        ),
        "3"
    );
    assert_eq!(
        solve(
            r"8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1"
        ),
        "17517"
    );
    assert_eq!(
        solve(
            r"3
1 2 3
1 2 3"
        ),
        "0"
    );
}


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

int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int x[max(a,b)+1],n=0;
	for(int i=1;i<=max(a,b);i++){
		if(a%i==0&&b%i==0){
			n++;
			x[n]=i;
		}
	}
	sort(x+1,x+n+1);
	cout<<x[n-k+1]<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		
		int cnt=0;
		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)==T.charAt(i)) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
	}
	
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int sa=a.size(),sb=b.size(),sc=c.size();
  if(a[sa-1]==b[0]&&b[sb-1]==c[0]) prin("YES");
  else prin("NO");
  

  return 0;
}


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

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

    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    ll n, d;
    cin >> n >> d;
    ll cnt = 0;
    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const int maxn=1E5+5; 
ll n,sum,pre[maxn];
struct pt
{
	ll x,y;
	bool operator<(const pt&A)const
	{
		return max(x,y)<max(A.x,A.y);
	}
}a[maxn];
inline int get(int pos)
{
	int l=1,r=n,p=0,d=max(a[pos].x,a[pos].y);
	while(l<=r)
	{
		int mid=l+r>>1;
		long long uf=pre[mid];if(mid>=pos)uf-=d;
		if(uf<=sum)p=mid,l=mid+1;
		else r=mid-1;
	}return p;
	/*
	int l=1,r=n,mid;
	int d=max(a[pos].x,a[pos].y);
	while(l<r)
	{
		mid=(l+r+1)>>1;
		ll s=pre[mid]-(mid>=pos?d:0);
		if(s<=sum)
			l=mid;
		else
			r=mid-1;
	}
	return l;
	*/
}
ll gcd(ll x,ll y)
{
	if(y==0)
		return x;
	return x%y==0?y:gcd(y,x%y);
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i].x>>a[i].y;
		sum+=max((ll)0,a[i].y-a[i].x);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)
		pre[i]=pre[i-1]+max(a[i].x,a[i].y);
	ll ax=0,ay=1;
	for(int i=1;i<=n;++i)
	{
		int pos=get(i);
		ll s=sum-pre[pos];
		if(pos>=i)
			--pos,s+=max(a[i].x,a[i].y);
		if(a[i].y>a[i].x)
			s-=a[i].y-a[i].x;//!!!!!!!!!!!!! 
		ll x=(ll)pos*a[i].y+min(s+a[i].y-a[i].x,a[i].y);
		ll y=n*a[i].y;
		if(x<=0)
			continue;
		ll z=gcd(x,y);
		x/=z,y/=z;
		if((ld)ay*x>(ld)y*ax)
			ax=x,ay=y;
	}
	cout<<ax<<" "<<ay<<endl;
	return 0;
}


Measured memory_bytes: 5932
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s=0;cin>>n;
  for(int i=1;i<10;i++){
    for(int j=i;j<10;j++){
      if(n==i*j){s++;break;}
    }
    if(s>0)break;
  }
  if(s>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int X;
  cin >> X;
  if(30<=X) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();
		String s=sc.next();
		String t=sc.next();
		String ans="";
		for (int i=0;i<n;i++) {
			ans+=(char)s.charAt(i);
			ans+=(char)t.charAt(i);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int s[m];
    char c[m+1];
    for (int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }
    c[m] = '\0';
    char ans[n+1];
    ans[n] = '\0';
    for (int i = 0; i < n; i++) ans[i] = 'a';
    for (int i = 0; i < m; i++) {
        if (ans[s[i]-1] == 'a' || ans[s[i]-1] == c[i]) ans[s[i]-1] = c[i];
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    if (n != 1 && ans[0] == '0') {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (n != 1 && i == 0 && ans[0] == 'a') cout << 1;
        else if (ans[i] == 'a') cout << 0;
        else cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
 
public class Main{
  
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    
    for(int i = 0;i < 5;i++){
    	if(sc.nextInt() == 0) System.out.println(i+1);
    }
    
    
     
  }  
}


Measured memory_bytes: 35892
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <stack>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

ll mod = 1000000 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<pll> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

vvll nCr(1010,vll(1011,1)) ;

void tree_size(vvll &g,vll &cnt,int n){
	if(g.at(n).size()==0){
		cnt.at(n) = 1 ;
	}else{
		cnt.at(n) = 1 ;
		for(int i=0;i<g.at(n).size();i++){
			tree_size(g,cnt,g.at(n).at(i)) ;
			cnt.at(n) += cnt.at(g.at(n).at(i)) ;
		}
	}
}

ll solve(vvll &g,vll &cnt,int n){
	if(cnt.at(n)==2) return 1 ;
	ll res = 1 ;
	ll sum = cnt.at(n)-1 ;
	ll sub = 0 ;
	for(int i=0;i<g.at(n).size();i++){
		res = res*nCr.at(sum-sub).at(cnt.at(g.at(n).at(i)))%mod*solve(g,cnt,g.at(n).at(i))%mod ;
		sub += cnt.at(g.at(n).at(i)) ;
	}
	return res ;
}

int main(){
	for(int i=1;i<1010;i++){
		for(int j=1;j<i;j++){
			nCr.at(i).at(j) = nCr.at(i-1).at(j-1)+nCr.at(i-1).at(j) ;
			nCr.at(i).at(j) %= mod ;
		}
	}
	ll n ; cin >> n ;
	vvll g(n,vll(0)) ;
	vb root(n,true) ;
	for(int i=0;i<n-1;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		g.at(a).push_back(b) ;
		root.at(b) = false ;
	}
	ll s = -1 ;
	for(int i=0;i<n;i++){
		if(root.at(i)){
			s = i ;
			break ;
		}
	}
	vll cnt(n,0) ;
	tree_size(g,cnt,s) ;
	cout << solve(g,cnt,s) << endl ;
}



Measured memory_bytes: 11128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <string>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int Maxn = (int) 1e5;

int a[Maxn];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        a[l]++;
        a[r + 1]--;
    }
    for (int i = 0; i < n; ++i) {
        a[i + 1] += a[i];
    }

    int cnt = 0;
    for (int i = 0; i <= n; ++i) {
        if (a[i] >= m) ++cnt;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
	long int a, b;
	long int check = 0;

	scanf("%ld %ld", &a, &b);

	a = a % b;

	for (;;) {
		check = a - b;
		if (check < 0) {
			check = check * (-1);
		}

		if (a > check) {
			a = check;
		}

		else {
			printf("%ld", a);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vector<string> t(n);
  vector<bool> exist_b(n, false);
  vector<bool> exist_w(n, false);
  vecint cnt(n);
  for(auto p:index(t)) {
    cin>>p.value();
    int c=0;
    for(int j:irange(0,n)) {
      if(p.value()[j] == '#') {
        exist_b[j] = true;
      } else {
        exist_w[j] = true;
        ++c;
      }
    }
    cnt[p.index()] = c;
  }
  int mn = n*n;
  for(int i:irange(0,n)) {
    int cost = 2*cnt[i];
    if (exist_b[i] == false) ++cost;
    for(int j:irange(0,n)) {
      if (t[i][j] == '#') {
        if (exist_w[j]) {
          ++cost;
        }
      }
    }
    mn = min(mn, cost);
  }
  if(boost::count(exist_b, true) == 0) {
    cout<<-1<<endl;
  } else {
    cout<<mn<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
    int n, y;

    cin >> n >> y;

    for (int i = 0; i <= 2000; i++) {   // 10000円
        for (int j = 0; j <= 2000; j++) {   // 5000円
            int th = (y - (10000*i + 5000*j)) / 1000;
            if (th + i + j == n && th >= 0) {
                cout << i << " " << j << " " << th << endl;
                return (0);
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

// struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
// constexpr double PI  = acos(-1.0);
// constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
// inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    int n;
    map<int, int> m;
    int in;
    cin >> n;
    REP(i, 0, n) {
        cin >> in;
        ++m[in];
    }
    int cnt = 0;
    for (auto &p : m) {
        if (p.second % 2 != 0)
            ++cnt;
    }
    cout << cnt << endl;
}

int main() {
    solve();

    return 0;
}

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

#define int long long

using namespace std;

long long n, m;
string s[5000];
int dpD[2001][2001];
int dpU[2001][2001];
int dpR[2001][2001];
int dpL[2001][2001];

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

    for (int i = 0; i < m; i++) dpD[n - 1][i] = 0;
    for (int i = 0; i < m; i++) dpU[0][i] = 0;
    for (int i = 0; i < n; i++) dpR[i][m - 1] = 0;
    for (int i = 0; i < n; i++) dpL[i][0] = 0;

    for (int i = n - 2; i >= 0; i--)
    {
        for (int j = 0; j < m; j++)
        {
            if (s[i + 1][j] == '#')
                dpD[i][j] = 0;
            else
                dpD[i][j] = dpD[i + 1][j] + 1;
        }
    }

    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (s[i - 1][j] == '#')
                dpU[i][j] = 0;
            else
                dpU[i][j] = dpU[i - 1][j] + 1;
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j < m; j++)
        {
            if (s[i][j - 1] == '#')
                dpL[i][j] = 0;
            else
                dpL[i][j] = dpL[i][j - 1] + 1;
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = m - 2; j >= 0; j--)
        {
            if (s[i][j + 1] == '#')
                dpR[i][j] = 0;
            else
                dpR[i][j] = dpR[i][j + 1] + 1;
        }
    }

    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (s[i][j] != '#') ans = max(ans, dpD[i][j] + dpU[i][j] + dpR[i][j] + dpL[i][j] + 1);
        }
    }
    cout << ans;
}


Measured memory_bytes: 129536
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define int long long
const int maxd=1000000007,N=105000;
const double pi=acos(-1.0);
typedef long long ll;
struct node{
	ll t,d;
}a[N];
bool operator<(const node &p,const node &q)
{
	return ((p.d>q.d) || ((p.d==q.d) && (q.t>p.t)));
}
priority_queue<int,vector<int>,greater<int> > q;
vector<node> sel;
vector<int> num[N];
int n,k,cnt=0;
ll sum=0;
bool vis[N];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

signed main()
{
	n=read();k=read();
	int i;
	for (i=1;i<=n;i++)
	{
		a[i].t=read();a[i].d=read();
		num[a[i].t].push_back(a[i].d);
	}
	sort(a+1,a+1+n);
	for (i=1;i<N;i++)
	{
		if (!num[i].size()) continue;
		sort(num[i].begin(),num[i].end(),greater<int>());
		sel.push_back((node){i,num[i][0]});
	}
	sort(sel.begin(),sel.end());
	memset(vis,0,sizeof(vis));
	for (i=1;i<=k;i++)
	{
		if (!vis[a[i].t]) {vis[a[i].t]=1;cnt++;}
		else q.push(a[i].d);
		sum+=a[i].d;//cout << a[i].d << " ";
	}
	//for (i=1;i<=n;i++) cout << vis[i] << " ";cout << endl;
	//cout << endl;
	ll ans=sum+(ll)cnt*cnt;
	int len=sel.size();
	for (i=0;i<len;i++)
	{
		if (q.empty()) break;
		if (vis[sel[i].t]) continue;
		vis[sel[i].t]=1;
		sum+=(sel[i].d-q.top());
		q.pop();cnt++;
		ans=max(ans,sum+(ll)cnt*cnt);
	}
	cout << ans;
	return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

vector<bool> seen;
vector<int> first_order;
vector<int> last_order;

void dfs(Graph &G, int v, int& ptr) {
    first_order[v] = ptr++;
    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv]) continue;
        dfs(G, nv, ptr);
    }
    last_order[v] = ptr++;
}

int main() {
    int N;
    cin >> N;
    Graph G(N);
    for (int i = 0; i < N; ++i) {
        int u, k;
        cin >> u >> k;
        --u;
        for (int j = 0; j < k; ++j) {
            int v;
            cin >> v;
            --v;
            G[u].push_back(v);
        }
        sort(G[u].begin(), G[u].end());
    }
    seen.assign(N, false);
    first_order.assign(N, 0);
    last_order.assign(N, 0);
    int ptr = 0;
    for (int i = 0; i < N; ++i) {
        if (seen[i] == false) dfs(G, i, ptr);
    }

    for (int i = 0; i < N; ++i) {
        cout << i+1 << " " << first_order[i]+1 << " " << last_order[i]+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3160