akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
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; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    string s;
    cin >> s;
    reverse(all(s));
    string t[] = {"maerd", "remaerd", "esare", "resare"};
    rep(i, sz(s)) {
        int flg = 0;
        rep(j, 4) {
            rep(k, sz(t[j])) {
                if (i + k == sz(s)) break;
                if (t[j][k] != s[i + k]) break;
                
                if (k == sz(t[j]) - 1) {
                    flg = 1;
                    i += sz(t[j]) - 1;
                }
            }
        }
        if (flg == 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
using namespace std;
#define inRange(x,a,b) (a <= x && x <= b)

struct data{
    int x1, y1, x2, y2;
};

vector<string> vs;
vector<data> vd;
vector<int> depth;
map<string, vector<string>> child;

void init(){
    vs.clear();
    vd.clear();
    depth.clear();
    child.clear();
}

string str(int &pos, string s){
    string ret = "";
    while(s[pos] != '>')    ret += s[pos++];
    return ret;
}

int num(int &pos, string s){
    int ret = 0;
    while(isdigit(s[pos]))  ret = ret*10+s[pos++]-'0';
    return ret;
}

// return : name of root panel
string build(int &pos, int dep, const string s){
    pos++;  // <
    string name = str(pos, s);
    pos++;  // >
    vs.push_back(name);
    int c[4];
    for(int i = 0; i < 4; i++){
        c[i] = num(pos, s);
        if(i != 3)  pos++;  // ,
    }
    vd.push_back(data({c[0], c[1], c[2], c[3]}));
    depth.push_back(dep);
    while(s[pos+1] != '/'){
        child[name].push_back(build(pos, dep+1, s));
    }
    while(pos < s.length() && s[pos] != '>')    pos++;
    pos++;  // >
    return name;
}

int getPanel(int x, int y){
    int ret = -1, tmpdep = -1;
    for(int i = 0; i < vd.size(); i++){
        if(!inRange(x, vd[i].x1, vd[i].x2) || !inRange(y, vd[i].y1, vd[i].y2))  continue;
        if(depth[i] > tmpdep){
            tmpdep = depth[i];
            ret = i;
        }
    }
    return ret;
}

int main(){
    int n;
    while(cin >> n, n){
        string s;
        cin >> s;
        int pos = 0;
        init();
        build(pos, 0, s);
        for(int i = 0; i < n; i++){
            int x, y;
            cin >> x >> y;
            int panel = getPanel(x, y);
            if(panel == -1){
                cout << "OUT OF MAIN PANEL 1" << endl;
                continue;
            }
            cout << vs[panel] << " " << (int)child[vs[panel]].size() << endl;
        }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long double, long double > pdd;

#define vec vector
#define ALL(x) begin(x), end(x)

const int inf = 1e9;
const ll inf64 = 1e18;

int main() {

    ios_base::sync_with_stdio(0);

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    int n;

    cin >> n;

    vec< ll > a(n);
    ll sum = 0;

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

    int best = -1;

    for(int i = 0;i < n;i++) {
        if(best == -1) {
            best = i;
            continue;
        }
        ll was = std::abs( sum - 1ll * n * a[best] );
        ll now = std::abs( sum - 1ll * n * a[i] );
        if(now < was) best = i;
    }

    cout << best << "\n";

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



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

  string s = "";
  rep(i, n) {
    s += "X";
  }

  bool flg = true;
  rep(i, m) {
    int si;
    char ci;
    cin >> si >> ci;
    si -= 1;

    if (s[si] != 'X' && s[si] != ci) {
      flg = false;
    }
    s[si] = ci;
  }

  if (n == 1 && s[0] == 'X') {
    s[0] = '0';
  }
  else if (s[0] == 'X') {
    s[0] = '1';
  }
  rep1(i, n) {
    if (s[i] == 'X') {
      s[i] = '0';
    }
  }

  if ((n == 1 && s == "0") && flg) {
    cout << 0 << endl;
  }
  else if (s[0]=='0' || !flg) {
    cout << -1 << endl;
  } else {
    cout << s << endl;
  }

  return 0;
}

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

int main(int argc, char const *argv[]) {

  int n1, n2 = 0;
  char *m;
  char num1[5];
  m = (fgets(num1, sizeof(num1), stdin));
  sscanf(num1, "%d\n", &n1);

  if(n1 >= 82){
    n2 = 0;
  }else{
    for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        if ( (i * j) == n1) {
          n2 = 1;
          break;
        }
      }
      if (n2 == 1) break;
    }
  }

  if (n2 == 1) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,k;cin>>n>>k;
  n -= n/k*k;
  cout<<min(n, k-n)<<endl;
}

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


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

  int mod=1;
  rep(i,9){
    mod*=10;
  }
  mod+=7;

  vector<long> dp(s+1);
  dp[0]=1;
  for(int i=1;i<s+1;i++){
    for(int j=0;j<(i-3)+1;j++){
      dp[i]+=dp[j];
      dp[i]%=mod;
    }
  }
  
  cout<<dp[s]<<endl;
  return 0;

}


Measured memory_bytes: 3580
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())

//comment the below if now required

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second


#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const ll N = 2e5+1;

ll a[N];

bool sortbysec(const ll &a,const ll &b) 
{ 
    return (abs(a)>abs(b));
}

ll p,ans;

ll modinv(ll num,ll md)
{
    p = md-2;
    ans = 1;

    for(;p;num=(num*num)%md,p/=2)
    {
        if(p&1)
            ans = (ans*num)%md;
    }

    return ans;

} 

int  main()
{

    ll n,k,i,ans=1,p1=0,n1=0,f1=0,f2=0,p2=0,n2=0;

    cin>>n>>k;

    rep(i,1,n+1)
        cin>>a[i];


    sort(a+1,a+1+n,sortbysec);


    for(i=1;i<=k;++i)
            ans = (ans*a[i])%mod;

    if(ans>0)
    {
        cout<<ans<<"\n";
        return 0;
    }

    //find positive from k...1 and a negative from k...n

    for(i=k;i>=1;--i)
    {
        if(a[i]>0)
        {
            p1 = a[i];
            break;
        }
    }

    for(i=k+1;i<=n;++i)
    {
        if(a[i]<0)
        {
            n1 = a[i];
            break;
        }
    }

    if(p1!=0 && n1!=0)
        f1=1;

    for(i=k;i>=1;--i)
    {
        if(a[i]<0)
        {
            n2 = a[i];
            break;
        }
    }

    for(i=k+1;i<=n;++i)
    {
        if(a[i]>0)
        {
            p2 = a[i];
            break;
        }
    }

    if(p2!=0 && n2!=0)
        f2=1;


    if(f1==0 && f2==0)
    {
        ans = 1;
        for(i=n;i>=(n-k+1);--i)
        {
            ans = (ans*a[i])%mod;
        }

        ans = (ans+mod)%mod;

        cout<<ans;

        return 0;

    }

    if((f1 && f2==0) || (f1!=0 && f2!=0 && abs(n1*n2)>= abs(p1*p2)))
    {
        ans = (ans*n1)%mod;

        ans = (modinv(p1,mod)*ans)%mod;

        ans = (ans+mod)%mod;

        cout<<ans;

        return 0;

    }


        ans = (ans*p2)%mod;

        ans = (modinv(n2,mod)*ans)%mod;

        ans = (ans+mod)%mod;

        cout<<ans;


    return 0;
}

Measured memory_bytes: 5188
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A+1):
    for j in range(B+1):
        if (X-(i*500 + j*100)) / 50 <= C and X-(i*500 + j*100) >= 0:
            cnt+=1

print(cnt)


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

int co[MAXN][MAXN];
int ti[MAXN][MAXN];

int main() {
    int n, m, a, b;
    while (cin >> n >> m, n) {

        rep(i, m) {
            rep(j, m) {
                if(i==j) {
                    co[i][j] = 0;
                    ti[i][j] = 0;
                } else {
                    co[i][j] = INF;
                    ti[i][j] = INF;
                }
            }
        }

        int t, c;
        rep(i, n) {
            cin >> a >> b >> c >> t;
            --a; --b;
            co[a][b] = c;
            co[b][a] = c;
            ti[a][b] = t;
            ti[b][a] = t;
        }

        rep(k, m) {
            rep(i, m) {
                rep(j, m) {
                    ti[i][j] = min(ti[i][j], ti[i][k]+ti[k][j]);
                    co[i][j] = min(co[i][j], co[i][k]+co[k][j]);
                }
            }
        }

        int K, r;
        cin >> K;
        rep(re, K) {
            cin >> a >> b >> r;
            --a; --b;

            if (r) cout << ti[a][b] << endl;
            else cout << co[a][b] << endl;
        }
    }
}




Measured memory_bytes: 3772
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  string A,B,C;
  
  
  cin >> A >> B >> C;

  if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0]){
    cout << "YES" << endl;

  }else {
    cout << "NO" << endl;
  }
   return 0;
}


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

int n,m,x;
inline int getid(int vert,int temp)
{
	return vert * 401 + temp;
}
struct edge
{
	int to,cost;
	edge(int t_,int c_):to(t_),cost(c_){}
};
//N CCC...CCC HHH...HHH
vector<edge>graph[10000 * 401];
int dist[10000 * 401];
const int INF = 1004567890;
using P = pair<int,int>;
void dijkstra()
{
	fill(dist,dist + n * 401,INF);
	dist[0] = 0;
	priority_queue<P,vector<P>,greater<P> >que;
	que.push({0,0});
	while(!que.empty())
	{
		auto q = que.top();que.pop();
		int dis = q.first;
		int vid = q.second;
		if(dist[vid] < dis)continue;
		for(auto ed : graph[vid])
		{
			if(dist[ed.to] > dist[vid] + ed.cost)
			{
				dist[ed.to] = dist[vid] + ed.cost;
				que.push(P(dist[ed.to],ed.to));
			}
		}
	}
}
int t[10000];
void putline(int fr,int to,int cs)
{
	if(t[to] == 0 || t[to] == 2)
	{
		if(t[fr] == 1)
		{
			//1->0 or 1->2
			graph[getid(fr,0)].push_back(edge(getid(to,0),cs));
			for(int i = 1;i <= x;++i)
			{
				graph[getid(fr,i + t[to] * 100)].push_back(edge(getid(to,0),cs));
				if(i - 1 + cs >= x)
					graph[getid(fr,i + 200 - t[to] * 100)].push_back(edge(getid(to,0),cs));
			}
		}
		else if(t[fr] == t[to])
		{
			//0->0 or 2->2
			graph[getid(fr,0)].push_back(edge(getid(to,0),cs));
		}
		else
		{
			//0->2 or 2->0
			if(cs >= x)
				graph[getid(fr,0)].push_back(edge(getid(to,0),cs));
		}
	}
	else
	{
		if(t[fr] == 1)
		{
			//1->1
			graph[getid(fr,0)].push_back(edge(getid(to,0),cs));
			for(int i = 1;i <= x;++i)
			{
				if(i - 1 + cs >= x)
				{
					graph[getid(fr,i)].push_back(edge(getid(to,0),cs));
					graph[getid(fr,i + 200)].push_back(edge(getid(to,0),cs));
				}
				else
				{
					graph[getid(fr,i)].push_back(edge(getid(to,i + cs),cs));
					graph[getid(fr,i + 200)].push_back(edge(getid(to,i + cs + 200),cs));
				}
			}
		}
		else
		{
			//0->1 or 2->1
			if(cs >= x)
				graph[getid(fr,0)].push_back(edge(getid(to,0),cs));
			else
				graph[getid(fr,0)].push_back(edge(getid(to,cs + t[fr] * 100 + 1),cs));
		}
	}
}
int main()
{
	scanf("%d %d %d",&n,&m,&x);
	for(int i = 0;i < n;++i)
	{
		scanf("%d",t + i);
	}
	for(int j = 0;j < m;++j)
	{
		int a,b,d;
		scanf("%d %d %d",&a,&b,&d);
		--a;--b;
		putline(a,b,d);
		putline(b,a,d);
	}
	dijkstra();
	int ans = INF;
	for(int i = 0;i <= 400;++i)
	{
		ans = min(ans,dist[getid(n-1,i)]);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
	
	double r;
	cin>>r;
	double a = 6.28318530717958623200 ;
	double ans = a*r;
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;

	
	
	return 0;
}

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

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int tmp = v.at(0);
  int cnt = 1;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    // dum(cnt);
    if (tmp == v.at(i)) {
      cnt++;
    } else {
      if (cnt >= 2) {
        ans += cnt / 2;
      }
      cnt = 1;
      tmp = v.at(i);
    }
  }
  if (cnt >= 2) {
    ans += cnt / 2;
  }
  cout << ans << endl;
}

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

typedef long long ll;
int N;
ll arr[10000000];

int main()
{
	cin >> N;

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

	int cnt = 0;
	vector<int> ans;
	for(int i = N ; i > 1 ; i--){
		if(arr[i] > arr[i - 1]){
			ans.push_back(cnt);
			cnt = -1;
		}
		++cnt;
	}
	ans.push_back(cnt);
	sort(ans.begin(),ans.end());

	cout << ans[ans.size()-1] << '\n';

	return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
#include<stdlib.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m[1010],i,j,k,d[510][510]={};
  while(scanf("%d",&n),n){
    for(i=0;i<310*310;i++)d[i/310][i%310]=0;
    for(i=0;i<n;i++)scanf("%d",&m[i]);
    for(i=0;i<=n;i++){
      for(j=0;i+j<=n;j++){
	if(i<2)d[j][j+i]=0;
	else if(d[j+1][j+i-1]+2==i&&abs(m[j]-m[j+i-1])<2)d[j][j+i]=i;
	else{
	  for(k=j+1;k<i+j;k++)d[j][j+i]=MAX(d[j][j+i],d[j][k]+d[k][j+i]);
	}
      }
    }
    printf("%d\n",d[0][n]);
  }
  return 0;
}



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

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

  vector<int> town(n);
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    town.at(a-1)++;
    town.at(b-1)++;
  }
  for (int i = 0; i < n; i++) {
    cout << town.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long floor_sum(long long n, long long m, long long a, long long b){
    long long ans = 0;
    if (a >= m) { //小数点無視(k=[0,n-1]の(a/m)*kのΣ)
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) { //小数点無視(k=[0,n-1]の(b/m)のΣ)
        ans += n * (b / m);
        b %= m;
    }
    long long y_max = (a * n + b) / m;
    long long x_max = (y_max * m - b);
    if (y_max == 0) {//小数点以下完全無視
        return ans;
    }
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}
int main(){
  #define int long long
  int T;
  cin>>T;
  for(int i=0;i<T;i++){
    int N,M,A,B;
    cin>>N>>M>>A>>B;
    cout<<floor_sum(N,M,A,B)<<endl;
  }
}

Measured memory_bytes: 3548
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int n;

void solve(){
  set<string> in;
  map<string,int> sum;
  ll ans=0;
  int bet;
  rep(i,n){
    string t;
    cin >> t;
    int h,m;
    scanf(" %d:%d",&h,&m);
    char c;
    cin >> c >> t;
    if(c=='I' && in.count("000"))
      FOR(it,in) sum[*it] += h*60+m-bet;
    
    if(c=='I') in.insert(t);

    if(c=='O' && in.count("000"))
      FOR(it,in) sum[*it] += h*60+m-bet;
    
    if(c=='O') in.erase(t);
    bet=h*60+m;
  }
  ans=0;
  FOR(it,sum)
    if(it->F!="000")
      ans=max(ans,(ll)it->S);
  cout << ans << endl;
}


int main(int argc, char *argv[])
{
  while(cin >> n && n) solve();
  return 0;
}

Measured memory_bytes: 1308
package main

import "fmt"

func main() {
  var a, b int
  fmt.Scan(&a)
  fmt.Scan(&b)

  if a == b {
    fmt.Println("Draw")
  } else if a == 1 {
    fmt.Println("Alice")
  } else if b == 1 {
    fmt.Println("Bob")
  } else if a > b {
    fmt.Println("Alice")
  } else if a < b {
    fmt.Println("Bob")
  }
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int n;
	scanf( "%d", &n );
	
	unsigned long long int ans = 1ULL;
	for ( unsigned long long int i = 1ULL; i <= n; i++ )
	{
		ans = ans * i % 1000000007ULL;
	}
	
	printf( "%llu\n", ans );
	
	return 0;
}


Measured memory_bytes: 128
def main():
    N, A, B = map(int, input().split(' '))

    div = int(N / (A+B))
    sub = N - (A+B)*div

    ans = div*A
    if sub <= A:
        ans += sub
    else:
        ans += A
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N = list(map(int, input()))

m = 0 # 最小の枚数
m_ = 1 # 繰り上がり時の枚数

for n in N:
  m, m_ = min(m+n, m_ + 10-n), min(m+n + 1, m_ + 10-(n+1))
print(m)

Measured memory_bytes: 13504
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------

#define MAX 110000

ll dp[MAX];

int main(void) {
  pll a[MAX];
  ll h, w, d, L, R, temp2;
  cin >> h >> w >> d;

  FOR(i, 1, h+1) {
	FOR(j, 1, w+1) {
	  cin >> temp;
	  a[temp].first = i;
	  a[temp].second = j;
	}
  }

  cin >> n;

  FOR(i, 1, d+1) {
	temp = i;
	dp[temp] = 0;
	temp2 = temp + d;
	while (temp2 < h*w+1) {
	  dp[temp2] = llabs(a[temp2].first - a[temp].first) + llabs(a[temp2].second - a[temp].second) + dp[temp];
	  temp = temp2;
	  temp2 += d;
	}
  }

  FOR(i, 0, n) {
	cin >> L;
	cin >> R;
	ans = dp[R] - dp[L];
	cout << ans << endl;
  }

  return 0;
}

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

int main() {
	int n, t[110], m, p[110], x[110], sum_time;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> t[i];
	cin >> m;

	for (int i = 1; i <= m; i++) {
		sum_time = 0;
		cin >> p[i] >> x[i];
		for (int j = 1; j <= n; j++) {
			if (j == p[i]) sum_time += x[i];
			else sum_time += t[j];
		}
		cout << sum_time << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N, M, T;
	int[] a;

	public void solve() {
		N = nextInt();
		M = nextInt();
		T = nextInt();

		a = new int[N];

		for (int i = 0; i < N; i++) {
			a[i] = nextInt();
		}

		boolean flag = false;
		int now = 0;
		int ans = 0;
		for (int i = 0; i < N; i++) {
			if (flag) {
				now = a[i];
			} else {
				ans += a[i] - now - M;
				now = a[i];
			}
			if(i + 1 < N && now + 2 * M <= a[i + 1]){
				now += M;
				flag = false;
			}else{
				flag = true;
			}
			//out.println(ans);
		}

		if(flag)ans += Math.max(T - now - M, 0);
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24312
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector>

#define MIN(a, b) ((a)>(b)? (b): (a))

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    std::vector<long> h(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &(h[i]));
    }

    std::vector<long> c(n);

    c[0]=0;
    c[1]=abs(h[1]-h[0]);
    for(i=2; i<n; i++) {
        c[i]=MIN(c[i-2]+abs(h[i-2]-h[i]), c[i-1]+abs(h[i-1]-h[i]));
    }
    printf("%ld\n", c[n-1]);

    return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (N, Y) = readLine()!!.split(' ').map(String::toInt)
    for (i in 0..N) {
        for (j in 0..N) {
            val now = 10000 * i + 5000 * j
            if (i + j > N) break
            if (now + (N-i-j) * 1000 == Y) {
                println("$i $j ${N-i-j}")
                return
            }
        }
    }
    println("-1 -1 -1 ")
}

Measured memory_bytes: 38232
k, n = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
a.push(k+a[0])

max = 0

n.times do |i|
  sa = a[i+1] - a[i]
  max = max > sa ? max : sa
end

puts k - max

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

int main(){
  int N,n = 0;
  int f = 0;
  cin >> N;
  n = N;
  for(int i=0;i<8;i++){
    f += n%10;
    n /= 10;
  }
  if(N%f==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i,j,max = 0,ii,jj,nh,pt;
    scanf("%d%d",&ii,&jj);
    for (i = 1; i <= ii; i++){
        nh = 0;
        for (j = 1; j <= jj; j++){
            scanf("%d",&pt);
            nh = nh + pt ;
        }
        if (nh > max){
            max = nh;
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
void ABC42(void);
void ABC43(void);
void ABC44(void);
void ABC45(void);
void ABC46(void);
void ABC47(void);
void ABC48(void);
void ABC49(void);

int main(void){
    ABC49();
    return 0;
}

void ABC42(void){
    int a,b,c,n=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==7||b==7||c==7){
        if((a==5&&b==5)||(b==5&&c==5)||(c==5&&a==5)){
            printf("YES");
            n++;
    }}
    if(n==0)printf("NO");
}

void ABC43(void){
    int i,n,sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        sum+=i;
    }
    printf("%d",sum);
}

void ABC44(void){
    int n,k,x,y,i,sum=0;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(n>k){
        for(i=1;i<=k;i++)sum+=x;
        for(i=k+1;i<=n;i++)sum+=y;
    }else{
        for(i=1;i<=n;i++)sum+=x;
    }
    printf("%d",sum);
}

void ABC45(void){
    int a,b,h;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&h);
    printf("%d",(a+b)*h/2);
}

void ABC46(void){
    int a,b,c,n;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b||b==c||c==a){
        n=2;
        if(a==b&&a==c)n=1;
    }else{
        n=3;
    }
    printf("%d",n);
}

void ABC47(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a+b==c)||(b+c==a)||(c+a==b)){
        printf("Yes");
    }else{
        printf("No");
    }
}

void ABC48(void){
    char str1[100],str2[100];
    scanf("%s %s",str1,str2);
    printf("A%c",str2[0]);
    printf("C");
}

void ABC49(void){
    char c;
    scanf("%c",&c);
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        printf("vowel");
    }else{
        printf("consonant");
    }
}

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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') {
    cout << a + b << endl;
  }
  else if (op == '-') {
    cout << a - b << endl;
  }  
}


Measured memory_bytes: 3624
n = int(input())
a = map(int, input().split())
bs = list(map(int, input().split()))
cs = list(map(int, input().split()))

ans = 0

prev = -1
for i in a:
    ans += bs[i-1]
    if i == prev+1:
        ans += cs[i-2]
    prev = i

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n); rep (i, n) cin >> a[i];
    if (n % 2 == 0) {
        vector<ll> l(n / 2 + 1), r(n / 2 + 1);
        for (int i = 0; i * 2 < n; i++) {
            l[i + 1] = l[i] + a[2 * i];
        }
        for (int i = n / 2 - 1; i >= 0; i--) {
            r[i] = r[i + 1] + a[2 * i + 1];
        }
        rep (i, l.size()) eprintf("%lld ", l[i]); eprintf("\n");
        rep (i, r.size()) eprintf("%lld ", r[i]); eprintf("\n");
        ll ans = -(ll)1e18;
        rep (i, n / 2 + 1) chmax(ans, l[i] + r[i]);
        cout << ans << "\n";
    } else {
        vector<ll> l(n / 2 + 2), m(n / 2 + 1), r(n / 2 + 2);
        rep (i, n / 2 + 1) l[i + 1] = l[i] + a[2 * i];
        for (int i = n / 2; i >= 0; i--) r[i] = r[i + 1] + a[2 * i];
        for (int i = n / 2 - 1; i >= 0; i--) m[i] = m[i + 1] + a[2 * i + 1];
        rep (i, l.size()) eprintf("%4lld ", l[i]); eprintf("\n");
        rep (i, r.size()) eprintf("%4lld ", r[i]); eprintf("\n");
        rep (i, m.size()) eprintf("%4lld ", m[i]); eprintf("\n");

        vector<ll> mr(n / 2 + 1); mr[n / 2] = 0;
        reprev (i, n / 2) mr[i] = max(mr[i + 1] + a[1 + i * 2], r[i + 1]);
        rep (i, mr.size()) eprintf("%4lld ", mr[i]); eprintf("\n");
        ll ans = l[n / 2];
        rep (i, n / 2 + 1) chmax(ans, l[i] + mr[i]);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 7924
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        m: usize,
        b: [(usize, usize); m]
    };
    let mut cnt_h = vec![0; h+1];
    let mut cnt_w = vec![0; w+1];
    for &p in &b {
        cnt_h[p.0] += 1;
        cnt_w[p.1] += 1;
    }
    let max_h = *cnt_h.iter().max().unwrap();
    let max_w = *cnt_w.iter().max().unwrap();
    let overlap = cnt_h.iter().fold(0, |a, &x| a + if x == max_h { 1 } else { 0 }) * cnt_w.iter().fold(0, |a, &x| a + if x == max_w { 1 } else { 0 });
    let cover = b.iter().fold(0, |a, &(x, y)| a + if cnt_h[x] == max_h && cnt_w[y] == max_w { 1 } else { 0 });
    println!("{}", max_h + max_w - if cover == overlap { 1 } else { 0 });
}


Measured memory_bytes: 12968
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , m , l ;
    cin >> n >> m >> l ;
    vector<vector<int> > g(n, vector<int>(n, INF)) ;
    vector<vector<int> > dist(n, vector<int>(n, INF)) ;
    vector<vector<int> > dist2(n, vector<int>(n, INF)) ;
    vector<vector<int> > next(n, vector<int>(n, -1)) ;
    for(int i = 0; i < m; i++){
        int a , b , c ;
        cin >> a >> b >> c ;
        a--, b-- ;
        g[a][b] = c ;
        g[b][a] = c ;
        dist[a][b] = g[a][b] ;
        dist[b][a] = g[b][a] ;
    }
    for(int i = 0; i < n; i++){
        dist[i][i] = 0 ;
        dist2[i][i] = 0 ;
    }
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if ( dist[i][j] > dist[i][k] + dist[k][j] ){
                    dist[i][j] = dist[i][k] + dist[k][j] ;
                }
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if ( dist[i][j] <= l ) dist2[i][j] = 1;
        }
    }
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if ( dist2[i][j] > dist2[i][k] + dist2[k][j] ){
                    dist2[i][j] = dist2[i][k] + dist2[k][j] ;
                }
            }
        }
    }
    debug() << imie(dist) ;
    int q ;
    cin >> q; 
    while(q--){
        int a , b ;
        cin >> a >> b ;
        a--, b--;
        if ( dist2[a][b] == INF ) {
            cout << -1 << endl;
        }
        else cout << dist2[a][b] - 1 << endl;
    }
    return 0; 
}

Measured memory_bytes: 6104
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define INF 1e9

struct P
{
	int cost, state;

	bool operator >(const P& p) const{
		return cost > p.cost;
	}
};

int main() {
	int n;
	while(cin >> n, n){
		vvi stage_times(n, vi(n + 1));
		REP(i, n){
			REP(j, n + 1){
				cin >> stage_times[i][j];
			}
		}

		vi G(1 << n, INF);

		priority_queue<P, vector<P>, greater<P>> que;
		que.push({0, (1 << n) -1});

		int res = -1;
		while(!que.empty()){
			P p = que.top(); que.pop();
			if(p.state == 0){
				res = p.cost;
				break;
			}
			 // LOG("cost %d state %d\n", p.cost, p.state);

			REP(i, n){
				if(p.state & (1 << i)){//そのステージへ行ったことがない
					priority_queue<pii, vector<pii>, greater<pii>> costs;
					//装備を使わない
					costs.push({stage_times[i][0], 0});

					//なにか装備を使う
					REP(j, n){
						if (p.state & (1 << j)) continue; //そのステージをクリアしてないなら装備は使えない
						// LOG("can use %d\n", j);
						costs.push({stage_times[i][j + 1], j + 1});
					}

					int next_state = p.state & ~(1 << i);
					int next_cost = p.cost + costs.top().first;
					// LOG("cost %d use %d to %d\n",costs.top().first, costs.top().second, i);
					if (G[next_state] > next_cost){
						G[next_state] = next_cost;
						que.push({next_cost, next_state});
					}
				}
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 2132
#include <stdio.h>

int main(void){
    int x;
    scanf("%d", &x);

    int q,r;
    q=x/500;
    r=x%500;
    r=r/5;
    int happy=0;
    happy=q*1000+r*5;
    printf("%d\n", happy);

    return 0;
}


Measured memory_bytes: 128
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int A = cin.NextInt();
            int B = cin.NextInt();
            int ans = A + B;

            if (ans >= 10)
            {
                Console.WriteLine("error");
            }
            else
            {
                Console.WriteLine(ans);
            }

        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



Measured memory_bytes: 27472
n = gets.to_i
d = gets.chomp.split.map(&:to_i)

sorting = d.sort

count = 0

i = 0

while i < n
	if d[i] != sorting[i]
		count += 1
	end
	i += 1
end

if count == 0 || count == 2
	puts 'YES'
else
	puts 'NO'
end

Measured memory_bytes: 1788
#include<cmath>
#include<iostream>
#include<algorithm>
#include <string>
#include <stdexcept>
using namespace std; 
int main(){
  int a,b,c,d,e;
   char g[3]; string h,i;
    cin >> a>>b>>c;
 cout<<max({10*a+b+c,a+10*b+c,a+b+10*c});

  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:

    Int modmul(Int a, Int b) {
        return a * b % MOD;
    }

    void solve() {
        Int N;
        string S;

        cin >> N >> S;
        N *= 2;

        vector<int> LR(N);
        if (S[0] == 'W' || S.back() == 'W') {
            cout << 0 << endl;
            return;
        }

        LR[0] = 0;
        for (int i = 1; i < N; ++i) {
            if (S[i - 1] == S[i]) {
                LR[i] = 1 - LR[i - 1];
            } else {
                LR[i] = LR[i - 1];
            }
        }

        Int ans = 1;
        Int tapi = 0;
        for (int i = 0; i < N; ++i) {
            if (LR[i] == 0) {
                tapi++;
            } else {
                ans = modmul(ans, tapi);
                tapi--;
            }
        }
       
        if (tapi != 0) {
            cout << 0 << endl;
            return;
        }

        for (int i = 0; i < N / 2; ++i) {
            ans = modmul(ans, i + 1);
        }

        cout << ans << endl;


    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1404
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  vec A, B;

  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    A.pb(tmp);
  }
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    B.pb(tmp);
  }

  vec d;
  int ss = 0;
  for (int i = 0; i < N; i++) {
    int tmp = A[i] - B[i];
    d.pb(tmp);
    ss += tmp;
  }

  if (ss < 0) {
    cout << -1 << endl;
    return 0;
  }

  sort(ALL(d), greater<int>());

  int cont = 0;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < B[i]) {
      cont++;
      int tmp = B[i] - A[i];
      ss -= tmp;
      sum += tmp;
    }
  }

  for (int i = 0; i < N; i++) {
    if (sum <= 0) {
      cout << cont << endl;
      return 0;
    }
    sum -= d[i];
    cont++;
  }

  return 0;
}


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

// #define int long long

/* short */
#define pb push_back
#define print(Target) cout << Target << '\n'

/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

/* const */
const int INF = INT_MAX;

signed main()
{
  ios::sync_with_stdio(false);
  char c;
  int n, sum;
  cin >> n; sum = n;
  while (cin >> c, c != '='){
    cin >> n;
    if (c == '+') sum += n;
    if (c == '-') sum -= n;
    if (c == '*') sum *= n;
    if (c == '/') sum /= n;
  }
  print(sum);

  return (0);
}

Measured memory_bytes: 1196
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

main:-
    get_number(K),
    get_number(A),
    get_number(B),
    X is A div K,
    Y is B div K,
    (A mod K =:= 0 ; B mod K =:= 0 ; X \= Y) -> writeln('OK') ; writeln('NG').


Measured memory_bytes: 8052