akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextLong();
            var ans = 0L;
            ans += (n / 500) * 1000;
            var m = n % 500;
            ans += (m / 5) * 5;
            
            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 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 int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            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 long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            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;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    if (a * b < n) printf("-1\n");
    else if (a + b - 1 > n) printf("-1\n");
    else if (a == 1) {
        for (int i = n; i >= 1; i--) {
            printf("%d%c", i, i == 1 ? '\n' : ' ');
        }
    }
    else {
        int x = (n - b) / (a - 1);
        int y = (n - b) % (a - 1);
        int pos = b;
        for (int i = pos; i >= 1; i--) {
            if (i != pos) printf(" ");
            printf("%d", i);
        }
        for (int j = 1; j <= y; j++) {
            pos += x + 1;
            for (int i = pos; i >= pos - x; i--) {
                printf(" %d", i);
            }
        }
        for (int j = 1; j <= a - 1 - y; j++) {
            pos += x;
            for (int i = pos; i > pos - x; i--) {
                printf(" %d", i);
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
using namespace std;
int main(){
    int A,B,flag = 0;
    char ch[20];
    cin >> A >> B;
    cin >> ch;
    if(ch[A]!='-')  flag = 1;
    for(int i=0;ch[i]!='\0';i++){
        if(i!=A &&ch[i]!='0'&&ch[i]!='1'&&ch[i]!='2'&&ch[i]!='3'&&ch[i]!='4'&&ch[i]!='5'&&ch[i]!='6'&&ch[i]!='7'&&ch[i]!='8'&&ch[i]!='9')    flag = 1;
    }
    if(flag == 1)   cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<cstdio>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#define int long long
using namespace std;

signed main() {
	int MIN = 1 << 29;
	int a; cin >> a;
	for (int b = 1; b*b <= a; b++) {
		if (a%b == 0) {
			MIN = min(MIN, (int)max(to_string(b).length(), to_string(a/b).length()));
		}
	}
	cout << MIN << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() 
{
  	int n, a, b;
  	scanf("%d", &n);
  	scanf("%d %d", &a, &b);
  	for(int i = a; i <= b; i++)
  	{
  		if(i % n == 0)	
		{
			printf("OK\n");  
			return 0;	
		}	
	}
	printf("NG\n");
  	return 0;
}

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

template <class T> inline bool chmin(T& a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}
int INF = 100100100;

int main() {
  int N;
  cin >> N;
  vector<int> as(N);
  for(int i = 0; i < N; ++i) {
    cin >> as[i];
  }
  sort(as.begin(), as.end());
  int ans = INF;
  for(int base = as.front(); base <= as.back(); ++base) {
    int v = 0;
    for(auto a : as) {
      v += abs(a - base) * abs(a - base);
    }
    chmin(ans, v);
  }
  cout << ans << endl;
  return 0;
}

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

int main(void){
  int n, p, sum=0, p_max;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> p;

    if(i == 0) p_max=p;
    else{
      if(p_max < p) p_max=p;
    }

    sum+=p;
  }

  cout << sum - (p_max / 2) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    for(int x : a) {
        if(x % 2) {
            puts("first");
            return 0;
        }
    }
    puts("second");
    return 0;
}

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

int main(){
    int n,a,b;
    string str1;
    cin >> str1;
    cin >> n;
    for(int i=0; i<n; i++){
        string str2,str3;
        cin >> str2 >> a >> b;
        if(str2=="replace"){  //a文字目からb文字目までをpに置き換える
            cin >> str3;
            str1.replace(a, b-a+1, str3);
        }else if(str2=="reverse"){  //a文字目からb文字目まで逆順にする
            reverse(str1.begin()+a, str1.begin()+b+1);
        }else{
            cout << str1.substr(a, b-a+1) << endl;  //a文字目からb文字目までを出力
        }
    }
}


Measured memory_bytes: 3156
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const s = arg[0];
    
    let answer = [];
    
    for(let i=0; i<s.length; i++) {
        if(s[i] === "0") {
            answer.push(0);
        }
        
        if(s[i] === "1") {
            answer.push(1);
        }
        
        if(s[i] === "B" && answer.length > 0) {
            answer.pop();
        }
    }
    
    console.log(answer.join(""));
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22084
/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;

const int maxx=105;
int n,m,k;
int a[maxx];
int l[maxx],r[maxx];
bool ok;

void dfs(int i,int j, int k)
{
    if(i > 10)
    {
        ok = 1;
        return ;
    }
//    if(ok) return;
    if(a[i] > l[j-1])
    {
        l[j] = a[i];
        dfs(i+1,j+1,k);
    }
    if(a[i] > r[k-1])
    {
        r[k] = a[i];
        dfs(i+1,j,k+1);
    }
}

int main()
{
#ifdef LOCAL
    freopen("/Users/ecooodt/Desktop/c++ and acm/bai?/2.1/3.txt","r",stdin);
#endif
    int T;
    scanf("%d",&T);
    while(T--)
    {
        memset(r,0,sizeof(r));
        memset(l,0,sizeof(l));
        for(int i = 1; i <= 10; i++)
        {
            scanf("%d",&a[i]);
        }
        ok = 0;
        dfs(1,1,1);
        if(ok){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }

    return 0;
}

Measured memory_bytes: 3072
def main():
    width = int(input())
    grid = [input() for _ in range(2)]
    mod = 1000000007
    index = 0
    answer = 0
    former_grid = 0  # 1:上下同じ，0:上下が異なる
    while index < width:
        if index == 0:
            if grid[0][index] == grid[1][index]:
                answer = 3
                former_grid = 1
            else:
                answer = 6
                former_grid = 0
                index += 1
        else:
            if former_grid:
                # 直前が縦方向に置いていたとき
                answer = answer * 2 % mod
                if not grid[0][index] == grid[1][index]:
                    index += 1
                    former_grid = 0
            else:
                # 直前が横方向に置いていたとき
                if grid[0][index] == grid[1][index]:
                    former_grid = 1
                else:
                    answer = answer * 3 % mod
                    index += 1
        index += 1
    print(answer)


if __name__ == '__main__':
    main()



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

int main() {
  int n;
  cin >> n;
  vector<int> a(3 * n);
  rep(i, 3 * n) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    int idx = a.size() - 2 * (i + 1);
    ans += a[idx];
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4552
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
	double a, b, c, d, e, f;
	while ((cin >> a >> b >> c >> d >> e >> f)) {
		double x = (c*e - b*f) / (a*e - b*d);
		double y = (c*d - a*f) / (b*d - a*e);
                if(x==0)x=0;
                if(y==0)y=0;
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
}

Measured memory_bytes: 1280
n, m, x = map(int, input().split())
t = [list(map(int, input().split())) for _ in range (n)]
#print(t)

min = 10 ** 10
#ビット全探索
for i in range(2 ** n):
    #bag = []
    know = [0] * m
    total = 0
    flag = True
    for j in range(n):
        if (i >> j) & 1:
            #bag.append(t[j][0])
            total += t[j][0]
            for k in range(m):
                know[k] += t[j][k+1]
    #print(bag)
    #print(know)
    for j in range(m):
        if know[j] < x:
            flag = False
            break
    #print(flag)
    if flag and total < min:
        min = total

if min != 10** 10:
    print(min)
else:
    print(-1)

Measured memory_bytes: 9228
#include<iostream>
                #include<vector>
                #include<string>
                    using namespace std;
                     
                    int main() {
                    	long N,A,B;
                    	cin >> N >> A >> B;
                		if ((A-B) % 2 == 0)
                		{cout << (B-A)/2 << endl;
                		}
                      else{
                        cout << min(A-1,N-B)+(B-A+1)/2 << endl;
                        }
                      
                }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N,T,E,A;
  cin>>N>>T>>E;
  for(int i=0;i<N;i++){
    cin>>A;
    if(T%A<=E||A-T%A<=E){
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 2005;
const int MOD = 1e9 + 7;
int n, K;
int jc[MAXN * MAXN] = {1}, inv[MAXN * MAXN];
int f[MAXN][MAXN];

int quick_pow(int a, int x) {
    int res = 1;
    while (x) {
        if (x & 1)
            res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, x >>= 1;
    }
    return res;
}

int calc_C(int n, int r) {
    if (n < r)
        return 0;
    return 1ll * jc[n] * inv[r] % MOD * inv[n - r] % MOD;
}

int main() {
    scanf("%d %d", &n, &K);
    if (K == 1) {
        printf("1");
        return 0;
    }
    for (int i = 1; i <= MAXN * MAXN - 1; i++)
        jc[i] = 1ll * jc[i - 1] * i % MOD;
    inv[MAXN * MAXN - 1] = quick_pow(jc[MAXN * MAXN - 1], MOD - 2);
    for (int i = MAXN * MAXN - 1; i; i--)
        inv[i - 1] = 1ll * i * inv[i] % MOD;
    f[0][0] = 1;
    for (int i = 0; i <= n; i++)
        for (int j = i; j <= n; j++) {
            if (i != j)
                f[i + 1][j] = (f[i + 1][j] + f[i][j]) % MOD;
            f[i][j + 1] = (f[i][j + 1] + 1ll * f[i][j] * calc_C((j + 1) * (K - 1) + i - 1, K - 2) % MOD) % MOD;
        }
    printf("%lld", 1ll * f[n][n] * jc[n] % MOD);
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

typedef vector<ll> Edges;
typedef vector<Edges> Graph;

const ll V_MAX = 610; // !! SHOULD BE EDITTED !!
vector<ll> ts(V_MAX, -1);

bool topologicalSort(Graph &G){
	ll V = G.size();
	vector<ll> indeg(V, 0);
	queue<ll> qu;

	REP(i, V){
		REP(j, G[i].size()){
			indeg[G[i][j]]++;
		}
	}
	REP(i, V){
		if(!indeg[i]) qu.push(i);
	}

	ll idx = 0;
	while(!qu.empty()){
		ll s = qu.size();
		REP(i, s){
			ll now = qu.front();qu.pop();
			ts[now] = idx;
			idx++;
			REP(j, G[now].size()){
				ll next = G[now][j];
				indeg[next]--;
				if(!indeg[next]) qu.push(next);
			}
		}
	}

	return (idx == V);
}

vector<double> expect(Graph &G, vector<ll> &dag){
	ll N = G.size();
	vector<double> res(N, 0);
	for(int i=N-1;i>=0;i--){
		double tmp = 0;
		ll now = dag[i];
		ll dig = G[now].size();
		if(dig==0) continue;
		REP(j, G[now].size()){
			ll next = G[now][j];
			tmp += (1.0+res[next])/dig;
		}
		res[now] = tmp;
	}
	return res;
}

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

    ll N, M;
    cin >> N >> M;
    Graph G(N);
    REP(i, M){
    	ll s, t;
    	cin >> s >> t;
    	s--, t--;
    	G[s].push_back(t);
    }
    topologicalSort(G);
    vector<pll> jun;
    REP(i, N){
    	jun.push_back({ts[i], i});
    }
    sort(jun.begin(), jun.end());
    vector<ll> dag(N);
    REP(i, N) dag[i] = jun[i].second;
    //cout << dag <<endl;

    auto kitai = expect(G, dag);

    double res = kitai[0];
    //bool flag = false;
    REP(i, N-1){
    	if(G[i].size()==1) continue;
    	//flag = true;
    	ll idx;
    	double ma = -1.0;
    	REP(j, G[i].size()){
    		ll next = G[i][j];
    		if(kitai[next]>ma){
    			ma = kitai[next];
    			idx = j;
    		}
    	}

    	Graph H(N);
    	REP(k, N){
    		REP(j, G[k].size()){
    			if(k == i && j == idx) continue;
    			H[k].push_back(G[k][j]);
    		}
    	}

    	auto ima = expect(H, dag);
    	res = min(ima[0], res);
    }
    printf("%.10f\n", res);
    return 0;
}

Measured memory_bytes: 4528
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * n / 2 + (m - 1) * m / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template <typename X>
struct BIT
{
  vector<X> dat;
  int n;

  BIT(ll _n){
    n = _n+1;
    dat.assign(n,0);
  }
  
  X sum(ll i)
  {
    X s = 0;
    while(i > 0){
      s += dat[i];
      i -= i&(-i);
    }
    return s;
  }

  void add(ll i,X x)
  {
    while(i<=n){
      dat[i] += x;
      i += i&(-i);
    }
  }
};

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<pair<ll,ll>> p(n);
  rep(i,n){
    p[i]=make_pair(a[i],i);
  }

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

  BIT<ll> bit(n);

  vector<ll> res(n);
  rep(i,n) res[i] = 0;
  ll pod=0;
  ll level=0;

  rep(i,n){
    bit.add(p[i].second+1,1);
    if(bit.sum(p[i].second+1)==p[i].second+1){
      res[p[i].second] += (n-i)*(p[i].first-level);
      res[p[i].second] += pod;
      pod = 0;
      level = p[i].first;
    }
    else{
      pod += p[i].first-level;
    }
  }

  rep(i,n) cout << res[i] << "\n";
  
  return 0;
}


Measured memory_bytes: 4992
#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 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);
  };
};

string s;

signed main() {
  cin >> s;

  int contW = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'W') contW++;
  }

  int sum = 0, num = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'W') {
      sum += i - num;
      num++;
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 640
N = int(input())
AC, WA, TLE, RE = 0, 0, 0, 0

for i in range(N):
    S = input().strip()
    if S == "AC":
        AC += 1
    elif S == "WA":
        WA += 1
    elif S == "TLE":
        TLE += 1
    elif S == "RE":
        RE += 1

print("AC x %d" % AC)
print("WA x %d" % WA)
print("TLE x %d" % TLE)
print("RE x %d" % RE)


Measured memory_bytes: 9188
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        xs: [i32; 5],
    }
    for (i, x) in xs.into_iter().enumerate() {
        if x == 0 {
            println!("{}", i + 1);
            return;
        }
    }
}


Measured memory_bytes: 2128
N = int(input())
W = [input() for _ in range(N)]
for i in range(N-1):
  if W[i][-1] != W[i+1][0]:
    print("No")
    exit()
else:
  if len(W) != len(list(set(W))):
    print("No")
    exit()
  else:
    print("Yes")
  

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

int cnt[10][10];

int main() {
	int x, y, s; char c;
	while(cin >> x >> c >> y >> c >> s) {
		for(int i = 0; i < 10; i ++)
			for(int j = 0; j < 10; j ++)
				if(s == 2) {
					if(abs(x - i) <= 1 && abs(y - j) <= 1)
						cnt[i][j] ++;
				} else {
					if(abs(x - i) + abs(y - j) <= s / 2 + 1)
						cnt[i][j] ++;
				}
	}
	auto a = (int*)cnt;
	cout << count(a, a + 100, 0) << '\n';
	cout << *max_element(a, a + 100) << '\n';
	return 0;
}

Measured memory_bytes: 2984
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}

ll getdigit(ll n){
	string s=to_string(n);
	return s.size();
}
	
int main(){
	init();
	ll n,m;cin>>n>>m;
	vector<ll>x(n);
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	vector<ll>y(m);
	for(int i=0;i<m;i++){
		cin>>y[i];
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	ll numX=0;
	for(int i=0;i<n-1;i++){
		ll num=abs(x[i+1]-x[i])%MOD*(i+1)%MOD*(n-i-1);
		num%=MOD;
		numX+=num;
		numX%=MOD;
	}
	ll numY=0;
	for(int i=0;i<m-1;i++){
		ll num=abs(y[i+1]-y[i])%MOD*(i+1)%MOD*(m-i-1);
		num%=MOD;
		numY+=num;
		numY%=MOD;
	}
	cout<<numY*numX%MOD<<endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

int dp[102][10004];

int knapsack(int N, int W, int v[], int w[]) {
	//int dp[102][10004];
	REP(i, N + 1) {
		REP(j, W + 1) dp[i][j] = -1;//?????????
	}

	REP(i, N + 1) dp[i][0] = 0; //???????????¶???????????§?????????0????????????????????§???0
	REP(j, W + 1) dp[0][j] = 0; //???????????°???0????????????????????§???0


	int dia, top;
	for (int i = 1;i <= N;i++) {
		for (int j = 1;j <= W;j++) {
			if (j - w[i] >= 0) dia = dp[i - 1][j - w[i]] + v[i];//i??????????????????????????????
			else dia = 0;
			top = dp[i - 1][j];//i???????????????????????°????????£?????¨???
			dp[i][j] = max(dia, top);
		}
	}

	return dp[N][W];
}

int main() {
	int N, W;
	cin >> N >> W;

	int v[102], w[102];
	for(int i = 1; i <= N; i++) {//1-origin
		cin >> v[i] >> w[i];
	}


	int ans = knapsack(N, W, v, w);

	cout << ans << endl;
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

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

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a = inf,b,ans=-inf;
  cin >> n;
  rep(i,n){
    cin >> b;
    ans = max(b - a,ans);
    a = min(a,b);
  }
  cout << ans << endl;
  return 0;
}

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

long long gcd(long long, long long);

int main()
{
    int n;
    long long lcm{1};
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        long long t;
        scanf("%lld", &t);
        lcm = lcm / gcd(t, lcm) * t;
    }
    printf("%lld\n", lcm);

    return 0;
}

long long gcd(long long a, long long b)
{
    while (a != 0)
    {
        b %= a;
        std::swap(a, b);
    }
    return b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;
    int ans = 0;
    vi a(n);

    fo(i, n) cin >> a[i];
    sort(all(a), greater<int>());

    fo(i, n) {
        if ( i & 1 ) ans -= a[i];
        else ans += a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29



def main():
    X = iRaw()
    d500 = X//500
    d5 = (X%500)//5
    return d500*1000+d5*5

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38256
N, W = [int(i) for i in input().split()]
wv = []
for i in range(N):
  wv.append([int(i) for i in input().split()])
dp = [[0 for i in range(W+1)] for j in range(N+1)]
#print(wv)

for i in range(1,N+1):
  for w in range(W+1):
    #print(i,w)
    if w >= wv[i-1][0]:
      dp[i][w] = max(dp[i-1][w], dp[i-1][w-wv[i-1][0]] + wv[i-1][1])
    else:
      dp[i][w] = dp[i-1][w]
print(dp[N][W])


Measured memory_bytes: 217896
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

transport = [A, B, C, D, E]
bottleneck = min(transport)
time = 0
reached = 0

time = math.ceil(N / bottleneck) + 4

print(time)

Measured memory_bytes: 3064
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) a.begin(),a.end()
using namespace std;

int main()
{
	vector<int> A;
	rep(i, 3) {
		int x;
		cin >> x;
		A.push_back(x);
	}
	sort(all(A));
	int ans = A[0] + A[1] + A[2] * 10;
	cout << ans << endl;
	
	return 0;


}



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

using lint = long long;
char A[200010];
char B[400110];
lint cnt[26];
int R[400110];
int main() {
	scanf("%s", A);
	lint n = strlen(A);
	lint ans = n*(n-1)/2+1;
	for (int i = 0; i < n; i++) {
		cnt[A[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		ans -= cnt[i] * (cnt[i] - 1) / 2;
	}
	printf("%lld", ans);


}

Measured memory_bytes: 512
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N,M = MI()
adj = [[] for _ in range(N+1)]
for _ in range(M):
    a,b = MI()
    adj[a].append(b)
    adj[b].append(a)

q = deque()
q.append(1)
d = [0]*(N+1)
d[1]=1
while q:
    u = q.popleft()
    for v in adj[u]:
        if d[v]!=0:
            continue
        q.append(v)
        d[v]=u
isOK = True
for i in range(2,N+1):
    if d[i]==0:
        isOK = False
if isOK:
    print('Yes')
    for j in range(2,N+1):
        print(d[j])
else:
    print('No')


Measured memory_bytes: 93580
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;

#define A first
#define B second

typedef long long ll;
constexpr int MOD = 1000000007;

void solve() {
  ll N, D;
  cin >> N >> D;
  int 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;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define f              first
#define s              second
#define gc getchar_unlocked
#define fo(i,start,end) for(int i=start;i<end;i++)
#define FORR(i,end,start) for(int i=end-1;i>start;i--)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf std::numeric_limits<double>::infinity()
//#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define INPUT(a,n) fo(i,0,n) cin>>a[i];
#define INPUT2d(a,n,k) fo(i,0,n) fo(j,0,k) cin>>a[i][j];
#define mk(a,n,type)  type *a=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define SIZE 100005
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

// void solve() {
  
// }

int32_t main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif


    // ll t;
    // cin >> t;
    // while(t--) {
      ll  m,n,o;cin>>m>>n>>o;
cout<<((m+n-1)/n)*o<<'\n';
//  if(m==n)cout<<(m/n)*o<<'\n';
//   else cout<<o<<'\n';

    //}

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
 	}
 }

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

using namespace std;

#define ll long long

//#define TEST

struct edge {
	int from = 0, to = 0; ll weight = 0;
	int cnt = 0;
	ll evl = 0; // 評価値
	edge() {}
	edge(int f, int t, ll w) {
		from = f;
		to = t;
		weight = w;
	}
};

int n, s, e;
ll t;
vector<vector<edge*>> g; // 隣接リスト
edge es[100000];
vector<int> parent;

void dfs(int s) { // parentを構築する
	for (auto eg : g[s]) {
		if (eg->from == s && parent[eg->to] == -1) {
			parent[eg->to] = s;
			dfs(eg->to);
		}
		else if (eg->to == s && parent[eg->from] == -1) {
			parent[eg->from] = s;
			dfs(eg->from);
		}
	}
}

void visit(int i) {
	for (auto eg : g[i]) {
		eg->weight -= t;
	}
}

int got = 1;
vector<int> visited;
void solve(int s) {
	for (auto eg : g[s]) {
		int to;
		if (eg->from == s)
			to = eg->to;
		else
			to = eg->from;
		if (visited[to])
			continue;
		if (eg->weight <= 0) {
			cout << "No" << endl;
			exit(0);
		}
		visit(to);
		visited[to] = 1;
		++got;
		solve(to);
		if (eg->weight <= 0) {
			cout << "No" << endl;
			exit(0);
		}
		visit(s);
	}
	if (got == n && s == e) {
		cout << "Yes" << endl;
		exit(0);
	}
}

signed main() {
	cin >> n >> t >> s >> e;
	--s; --e;

	g.resize(n);
	parent.resize(n, -1);

	for (int i = 0; i < n - 1; ++i) {
		int a, b; ll w;
		cin >> a >> b >> w;
		--a; --b;
		edge eg(a, b, w);
		es[i] = eg;
		g[a].push_back(es + i);
		g[b].push_back(es + i);
	}

#ifdef TEST
	cout << "------------es------------" << endl;
	for (int i = 0; i < n - 1; ++i) {
		auto eg = es[i];
		cout << (eg.from) << " " << (eg.to) << " " << (eg.weight) << endl;
	}
#endif

	parent[s] = s;
	dfs(s);

#ifdef TEST
	cout << "----------parent----------" << endl;
	for (auto pi : parent)
		cout << pi << " ";
	cout << endl;
#endif

	vector<int> cnt(n, 1); // 頂点iを何回訪れるか
	cnt[s] -= 2;
	for (auto pi : parent)
		cnt[pi]++;
	int now = e; int prt = parent[e];
	while (now != prt) {
		cnt[prt]--;
		now = prt;
		prt = parent[now];
	}

#ifdef TEST
	cout << "------------cnt-----------" << endl;
	for (auto ci : cnt)
		cout << ci << " ";
	cout << endl;
#endif

	for (int i = 0; i < n - 1; ++i) {
		es[i].cnt = cnt[es[i].from] + cnt[es[i].to];
		es[i].evl = es[i].weight - t * es[i].cnt;
	}

	now = e; prt = parent[e];
	while (now != prt) {
		for (auto eg : g[now]) {
			if ((*eg).from == now && (*eg).to == prt) {
				(*eg).evl = INT_MAX;
				break;
			}
			else if ((*eg).from == prt && (*eg).to == now) {
				(*eg).evl = INT_MAX;
				break;
			}
		}
		now = prt;
		prt = parent[now];
	}

#ifdef TEST
	cout << "-----------edge-----------" << endl;
	for (int i = 0; i < n - 1; ++i) {
		auto eg = es[i];
		cout << (eg.from) << " " << (eg.to) << " " << (eg.evl) << endl;
	}
#endif

	for (int i = 0; i < n; ++i) {
		sort(
			g[i].begin(),
			g[i].end(),
			[](const edge* e1, const edge* e2) {return (e1->evl < e2->evl); }
		);
	}

#ifdef TEST
	cout << "----------edge(sorted)-----" << endl;
	for (int i = 0; i < n; ++i) {
		cout << "i=" << i << endl;
		for (auto eg : g[i])
			cout << (eg->from) << " " << (eg->to) << " " << (eg->evl) << endl;
	}
#endif

	visited.resize(n, 0);
	visited[s] = 1;

	solve(s);

	return 0;
	}


Measured memory_bytes: 14420
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');

var n = lines.shift() - 0;

var r = [];

for (var i = 1; i <= n; i++) {
    var arr = lines.shift().split(' ');
    r[i] = +arr[0];
    r[i + 1] = +arr[1];
}

var cost = [[-1]];
for (var i = 1; i <= n; i++) {
    var arr = [-1];
    cost.push(arr);
    for (var j = 1; j <= n; j++) {
        cost[i][j] = Number.POSITIVE_INFINITY;
    }
}

for (var i = 1; i <= n; i++) {
    cost[i][i] = 0;
}

for (var j = 1; j < n; j++) {
    for (var i = 1; i <= n - j; i++) {
        for (var k = i + 1; k <= i + j; k++) {
            var c = cost[i][k - 1] + cost[k][i + j] + r[i] * r[k] * r[i + j + 1];
            if (c < cost[i][i + j]) {
                cost[i][i + j] = c;
            }
        }
    }
}

console.log(cost[1][n]);

Measured memory_bytes: 9804
#include<stdio.h>
#include<math.h>
int main()
{
    int l,t;
    double x = 0,y = 0,r = M_PI / 2;
    while(1){
        scanf("%d,%d",&l,&t);
        if(l == 0 && t == 0) break;
        x += cos(r) * l;
        y += sin(r) * l;
        r += t * M_PI / 180;
    }
    printf("%d\n%d\n",(int)-x,(int)y);
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int A, B;
  cin >> A >> B;
  if(A <= 5) cout << 0 << endl;
  else if(A >= 13) cout << B << endl;
  else cout << B / 2 << endl;
}





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

int main() {
  char a;
  cin >> a;
  bool ans = false;
  for(int i = 0; i < 26; i++){
    if(a=='A'+i){
      ans = true;
      break;
    }
  }
  
  if(ans){
    cout << 'A' << endl;
  }
  else{
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3628
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var k = next();
  var s = nextstr();
  return s.length <= k ? s : s.slice(0,k) + "...";
}

Measured memory_bytes: 29640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=0; i<=n; i++)

int main()
{
	int a, b, k;
	
	scanf("%d %d", &a, &b);
	
	k=(a+b)/2;
	
	if(a%2!=b%2){ printf("IMPOSSIBLE"); }
	else { printf("%d", k); }
	
	return 0;
}

Measured memory_bytes: 128
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

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

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int H,W;
vector<vector<string>> V;

signed main(){

    in(H,W);
    resize(V,H,W);
    rep(i,H) rep(j,W) in(V[i][j]);

    rep(i,H){
        rep(j,W){
            if(V[i][j]=="snuke"){
                cout<<(char)('A'+j)<<i+1<<endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <set>
#include <utility>
#include <iostream>
#include <cassert>
#include <stack>
#include <climits>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define rvc(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;
 
const int N=200005;
int n;
LL ai[N];
LL f[N][5];
LL s[N];
 
/*
A      B
111111 222222
C       D    E
222222 11111 222222
 
nil -> A,C
 
A -> A,B
B -> B
C -> C,D
D -> D,E
E -> E
 
*/
 
int main(){
    scanf("%d",&n);
    rep(i,1,n){
        cin>>ai[i];
        s[i]=s[i-1]+ai[i];
        if(ai[i]!=0){
            if(ai[i]%2)ai[i]=1;
            else ai[i]=2;
        }
    }
    LL ans=s[n];
    rep(i,1,n){
     //   f[i][0]=min(f[i-1][0],s[i-1])+abs(ai[i]-1);
      //  f[i][1]=min(f[i-1][0],f[i-1][1])+abs(ai[i]-2);
        f[i][2]=min(s[i-1],min(f[i-1][2],s[i-1]))+abs(ai[i]-2);
        f[i][3]=min(s[i-1],min(f[i-1][3],f[i-1][2]))+abs(ai[i]-1);
        f[i][4]=min(s[i-1],min(f[i-1][4],f[i-1][3]))+abs(ai[i]-2);
        rep(j,2,4)ans=min(ans,f[i][j]+s[n]-s[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int N,K;
	cin >> N >> K;
	if(N%K==0) cout << 0 << endl;
	else cout << 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256