akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
    int h, n;
    cin >> h >> n;
    for(int i = 0; i < n; i++){
        int d;
        cin >> d;
        h -= d;
    }
    if(h <= 0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<ll>sum(n);
	bool flag = false;
	rep(i, n) {
		int a;
		cin >> a;
		if (flag) {
			sum[i] = sum[i - 1] + a;
		}
		else {
			sum[i] = a;
			flag = true;
		}
	}
	ll tmp = 1e10;
	rep(i, n-1) {
			tmp = min(tmp,abs(sum[n - 1] - sum[i] * 2));
	}
	cout << tmp << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<unordered_map>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>

using namespace std;
int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
#define INF 99999999999 
#define pb push_back
#define mt make_tuple
#define ll long long
ll lncr(ll n, ll r)
{
	ll i, ans = 1, k = 0;
	if (r == 0)
		return 1;
	else if (n < r)
		return 0;
	for (i = n; i >= n - r + 1; i--)
	{
		ans *= i;
		ans /= n - i + 1;
	}


	return ans;

}
bool visited[6] = { false };
int n = 6;
vector<int> adj[6];


void max_heapify(int a[100], int i)
{
	int l, r, largest = i;
	l = 2 * i + 1;
	r = 2 * i + 2;
	if (l<n && a[l]>a[i])
		largest = l;
	if (r<n && a[r]>a[l])
		largest = r;
	if (largest != i)
	{
		int k;
		k = a[i];
		a[i] = a[largest];
		a[largest] = k;
		max_heapify(a, largest);
	}

}
int power(ll x, ll y, ll p)
{
	int res = 1;
	x = x % p;

	while (y > 0)
	{

		if (y & 1)
			//res = (res * x) % p;


		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

bool square(ll n)
{
	double x;
	x = sqrt(n);
	if (x == floor(x))
		return true;
	else return false;
}


bool prime(ll n)
{
	ll i;
	for (i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
			return false;
	}
	return true;
}
void dfs(ll a, ll b, vector<pair<ll, ll>>adj[][1001], bool visited[][1001])
{
	visited[a][b] = true;
	for (auto u : adj[a][b])
	{
		if (!visited[get<0>(u)][get<1>(u)])
		{
			visited[get<0>(u)][get<1>(u)] = true;
			dfs(get<0>(u), get<1>(u), adj, visited);
		}
	}
}
ll day(ll d, ll m, ll y)
{
	static int t[] = { 0, 3, 2, 5, 0, 3,
				   5, 1, 4, 6, 2, 4 };
	y -= m < 3;
	return (y + y / 4 - y / 100 +
		y / 400 + t[m - 1] + d) % 7;
}
bool leap(int year)
{
	if (year % 400 == 0)
		return true;
	if (year % 100 == 0)
		return false;
	if (year % 4 == 0)
		return true;
	return false;
}
int main()
{
	ll n, arr[100001], dp[100001] = { 0 }, i, k, j;
	cin >> n >> k;
	for (i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = 0;
	for (i = 2; i <= k + 1; i++) {
		dp[i] = abs(arr[i] - arr[1]);
	}
	for (i = k + 2; i <= n; i++) {
		dp[i] = INF;
		for (j = 1; j <= k; j++) {
				dp[i] = min(dp[i - j] + abs(arr[i] - arr[i - j]),dp[i]);
		}
		
		
	}
	//for (i = 1; i <= n; i++) {
	//	cout << dp[i]<<" ";
	//}
	cout << dp[n] << endl;
}

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

int N,M;
int t[60];

int main()
{
    cin>>N>>M;

    for (int i = 1; i <= N; i++)
    {
        t[i] = 0;
    }
    
    for (int i = 0; i < M; i++)
    {
        int a,b;
        cin>>a>>b;
        t[a]++;
        t[b]++;
    }
    
    for (int i = 1; i <= N; i++)
    {
        cout << t[i] << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	int maxL = -1;
	int sum = 0;
	for(int i = 0; i < n; ++i) {
		int L;
		cin >> L;
		
		sum += L;
		maxL = max(maxL, L);
	}
	
	if( sum - maxL > maxL ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);
    
  sort(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    cout << S.at(i);
  }

}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

S = input()

num_abc = dict()
num_abc["a"] = 0
num_abc["b"] = 0
num_abc["c"] = 0

for i in range(len(S)):
	num_abc[S[i]] += 1

a = num_abc["a"]
b = num_abc["b"]
c = num_abc["c"]

if max(a, b, c) - min(a, b, c) <= 1:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 39280
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;

typedef long long int ll;

int main(){
    int N, K;
    cin >> N >> K;
    if(N-2*K>0)
    cout << N-2*K;
    else cout <<0;



}

Measured memory_bytes: 256
from itertools import accumulate
import heapq
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
first_item = list(map(int, input().split()))
basew = first_item[0]
w0 = []
w1 = []
w2 = []
w3 = []
w0.append(first_item[1])
for _ in range(N-1):
    w, v = map(int, input().split())
    w -= basew
    if w == 0:
        w0.append(v)
    elif w == 1:
        w1.append(v)
    elif w == 2:
        w2.append(v)
    elif w == 3:
        w3.append(v)

w0_acc = [0]+list(accumulate(sorted(w0, reverse=True)))
w1_acc = [0]+list(accumulate(sorted(w1, reverse=True)))
w2_acc = [0]+list(accumulate(sorted(w2, reverse=True)))
w3_acc = [0]+list(accumulate(sorted(w3, reverse=True)))
v = 0
for i0 in range(len(w0)+1):
    for i1 in range(len(w1)+1):
        for i2 in range(len(w2)+1):
            for i3 in range(len(w3)+1):
                if basew*(i0+i1+i2+i3)+3*i3 + 2*i2 + i1 > W:
                    break
                else:
                    v = max(v, w0_acc[i0]+w1_acc[i1]+w2_acc[i2]+w3_acc[i3])
print(v)


Measured memory_bytes: 41456
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;

int main()
{
	long long H, W;
	cin >> H >> W;
	long long a, b, c, Min= 1000000000000;

	for (int i = 1; i < H; i++) {
		a = i*W;
		b = (W / 2) * (H - i);
		c = H*W - a - b;
		Min = min(Min, max(a, max(b, c)) - min(a, min(b, c)));

		b = W*((H - i) / 2);
		c = H*W - a - b;
		Min = min(Min, max(a, max(b, c)) - min(a, min(b, c)));
	}

	for (int i = 1; i < W; i++) {
		a = i*H;
		b = (H / 2) * (W - i);
		c = H*W - a - b;
		Min = min(Min, max(a, max(b, c)) - min(a, min(b, c)));

		b = H*((W - i) / 2);
		c = H*W - a - b;
		Min = min(Min, max(a, max(b, c)) - min(a, min(b, c)));
	}

	cout << Min;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;

const int MAX = 100010;
const int INFTY = 1e10;

ll H[MAX];
int N;
ll A, B;

bool enoughT(ll T){
    ll tmp = 0;
    for(int i=lower_bound(H,H+N,(ll)T*B)-H; i<N;i++){
        tmp += (ll) ceil( (H[i] - T*B) / (double)(A-B));
    }
    return T >= tmp;
}

int main(){
    cin >> N >> A >> B;
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    sort(H, H+N);
    ll low = 0ll, up = INFTY;
    while(up - low > 1){
        ll middle = (low + up)/2;
        if(enoughT(middle)) up = middle;
        else                low = middle;
    }
    cout << up << endl;
    return 0;
}

Measured memory_bytes: 1024
#16D8103014C 安藤 陸人
#3_A
x = input().split()
flag = 0
j = -1
y = []
for i in range(len(x)):
    j = len(y) -1
    if x[i] == "+":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b+a)
    elif  x[i] == "-":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b-a)
    elif x[i] == "*":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b*a)
    else:
        y.append(int(x[i]))
print(y[0])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define r(i,a,n) for(int i=a;i<n;i++)
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	c-=a;d-=b;
	r(i,0,d)cout<<'U';
	r(i,0,c)cout<<'R';
	r(i,0,d)cout<<'D';
	r(i,0,c)cout<<'L';
	cout<<'L';
	r(i,0,d+1)cout<<'U';
	r(i,0,c+1)cout<<'R';
	cout<<"DR";
	r(i,0,d+1)cout<<'D';
	r(i,0,c+1)cout<<'L';
	cout<<'U';
	cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
 
int main()
{
    // get three integers
    int N, K;
    cin >> N >> K;
  	// Calculate
  	string S;
  	cin >> S;
  	string out="";
 

  	for ( int i=1; i<= N; i=i+1 ){
                if (i == K){
                 out += tolower(S[K-1]);
                }else{
                 out += S[i-1]; 
                }
    }
  	
 
    // output
    cout << out;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace T1PBC2019A
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            if (s[0] < s[1])
            {
                if (s[2] < s[1] && s[2] > s[0]) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }
            else
            {
                if (s[2] > s[1] && s[2] < s[0]) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }

            return;


        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long n,m,i;
	   string a[1000];
	cin>>n>>m;
	   for(i=1;i<=n;i++)
	   cin>>a[i];
	     sort(a,a+n+1);
	     for(i=1;i<=n;i++)
	      cout<<a[i];
	      cout<<endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;

int H, W, N;
int a;
vector<int> v;

int main() {
  cin >> H >> W >> N;
  for (int i = 1; i <= N; i++) {
    cin >> a;
    while (a--) {
      v.push_back(i);
    }
  }



  
  for (int i = 0; i < H; i++) {
    if (i & 1) reverse(v.begin() + i*W, v.begin() + (i+1)*W);

    for (int j = 0; j < W; j++) {
      cout << v[i*W+j] << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int X, Y, Z, K; cin >> X >> Y >> Z >> K;
  vi x(X), y(Y), z(Z);
  vi xy_sum, xyz_sum;
  rep(i, X) { cin >> x[i]; }
  rep(i, Y) { cin >> y[i]; }
  rep(i, Z) { cin >> z[i]; }
  rep(i, X) {
    rep(j, Y) {
      xy_sum.pb(x[i] + y[j]);
    }
  }
  sort(r_all(xy_sum));
  rep(i, min((int)xy_sum.size(), K)) {
    rep(j, Z) {
      xyz_sum.pb(xy_sum[i] + z[j]);
    }
  }
  sort(r_all(xyz_sum));
  rep(i, K) {
    cout << xyz_sum[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 42856
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {

	alpha_counter := make(map[rune]int)
	in_string := ""
	scanner := bufio.NewScanner(os.Stdin)

	for {
		if scanner.Scan() == false {
			break
		}
		in_string += scanner.Text()
	}

	for _, r := range in_string {

		if ('A' <= r) && (r <= 'Z') {
			r += 'a' - 'A'
		}

		if ('a' <= r) && (r <= 'z') {
			alpha_counter[r] += 1
		}
	}

	for i := 'a'; i <= 'z'; i++ {
		v, _ := alpha_counter[i]
		fmt.Printf("%c : %d\n", i, v)
	}
}



Measured memory_bytes: 1132
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define mod 1000000007
#define t() int tst;cin>>tst;for(int test=1;test<=tst;++test)
#define rep(i,a,b) for(i=a;i<b;++i)
#define repr(i,a,b) for(i=a;i>=b;--i)
typedef pair<int,int> pii;
#define F first
#define S second
#define pb push_back
#define all(p) p.begin(), p.end()
#define MAX 10000005

int powG(int x,int y)
{

  if(y==1)return x;
  if(y==0)return 1;

  int temp=powG(x,y/2);

  temp*= temp;

  if(y&1)
    temp*=x;
  
    return temp;
}

const int mx = 1e6 + 1;

bool dp[mx];


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //t()
    {
        int n;
        cin>>n;
        map<int,int> mp;
        int i;
        rep(i,0,n)
        {   
            int x;
            cin>>x;
            mp[x]++;
        }

        int count = 0;

        for(auto i :mp)
        {
            if(!dp[i.F])
            {
                if(i.S > 1)
                {
                    dp[i.F] = true;
                }
                else
                {
                    count++;
                }
                int j = i.F + i.F;
                for( ; j < mx; j += i.F)
                {
                    dp[j] = true;
                }
            }
        }

        cout << count;
    }
    return 0; 
} 





Measured memory_bytes: 17060
import sys

sys.setrecursionlimit(10**8)

n = int(input())
a = [i for i in range(1, n+1)]

def permute(deep, ans):
    if deep == 0:
        print(ans.strip())
    else:
        for i in a:
            if str(i) not in ans:
                permute(deep-1, ans+' '+str(i))

permute(n, '')


Measured memory_bytes: 5716
#include <stdio.h>
#include <string.h>

char S[100005];

int func(int K){

	int i;

	int len=strlen(S);

	if(len-K<=K-1){
		for(i=len-K;i<K-1;i++){
			if(S[i]!=S[i+1]){return 0;}
		}
	}
	return 1;
}

int main(){

	scanf("%s",S);

	int K=1;

	int l=1;
	int r=strlen(S);

	while(l<=r){
		int mid=(l+r)/2;
		if(func(mid)==1){
			if(K<mid){K=mid;}
			l=mid+1;
		}
		else{
			r=mid-1;
		}
	}

	printf("%d\n",K);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define mp make_pair
#define P pair
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#define modp(x, y) (((y) + (x) % (y)) % (y))
#define divd(x, y) (static_cast<double>(x) / static_cast<double>(y))

ll X, Y;

int main()
{
    //
    cin >> X >> Y;

    ll ans = 0, now = X;
    do {
        ans++;
        now *= 2;
    } while (now <= Y);
    cout << ans << endl;
}


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

int main () 
{
    int n,i,b;
    char a[10000];
    scanf("%d", &n);
    scanf("%s", a);
    b=strlen(a);

    for (i=0; i<b; i++) {
        a[i]=a[i]+n;
        if('A'<=a[i] && a[i]<='Z')
            a[i]=a[i];
        else
            a[i]=a[i]-26;
    }
    printf("%s\n",a);
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

int main() {
	ll yy, mm, dd;
	
	string s;
	cin >> s;
	
	yy = stoi(s.substr(0, 4));
	mm = stoi(s.substr(5, 2));

	bool preTime = true;

	if (yy > 2019) preTime = false;
	else if (mm > 4) preTime = false;

	if (preTime) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}

	return 0;
}

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

int main()
{
  
  
    map<string, int> days = {
      {"SUN", 7},
      {"MON", 6},
      {"TUE", 5},
      {"WED", 4},
      {"THU", 3},
      {"FRI", 2},
      {"SAT", 1}
    };
	
    string S;
    cin >> S;
    decltype(days)::iterator it = days.find(S);
    if (it != days.end()) { 
      cout << it->second << endl;
    }
    return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main(){
	string s;
	cin >> s;
	vector< char > res;
	int idx = 0;
	rep(i, len(s)){
		if(s[i] == '0' || s[i] == '1') res.add(s[i]);
		else if(s[i] == 'B' && len(res) > 0) res.pop_back();
	}
	rep(i, len(res)) cout << res[i];
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> count(n,0);
	rep(i,k) {
		int d;
		std::cin >> d;
		rep(j,d) {
			int a;
			std::cin >> a;
			a--;
			count[a]++;
		}
	}
	// count zeros
	int ans=0;
	rep(i,n) if(count[i]==0) ans++;
	print(ans);
	return 0;
}


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

#define MAX 50

int main() {
	int H, W;
	string S[MAX];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (S[h][w] == '#')
				continue;
			int cnt = 0;
			if (h - 1 >= 0 && w - 1 >= 0 && S[h - 1][w - 1] == '#')
				cnt++;
			if (h - 1 >= 0 && S[h - 1][w] == '#')
				cnt++;
			if (h - 1 >= 0 && w + 1 < W && S[h - 1][w + 1] == '#')
				cnt++;
			if (w - 1 >= 0 && S[h][w - 1] == '#')
				cnt++;
			if (S[h][w] == '#')
				cnt++;
			if (w + 1 < W && S[h][w + 1] == '#')
				cnt++;
			if (h + 1 < H && w - 1 >= 0 && S[h + 1][w - 1] == '#')
				cnt++;
			if (h + 1 < H && S[h + 1][w] == '#')
				cnt++;
			if (h + 1 < H && w + 1 < W && S[h + 1][w + 1] == '#')
				cnt++;
			switch (cnt) {
			case 0:
				S[h][w] = '0';
				break;
			case 1:
				S[h][w] = '1';
				break;
			case 2:
				S[h][w] = '2';
				break;
			case 3:
				S[h][w] = '3';
				break;
			case 4:
				S[h][w] = '4';
				break;
			case 5:
				S[h][w] = '5';
				break;
			case 6:
				S[h][w] = '6';
				break;
			case 7:
				S[h][w] = '7';
				break;
			case 8:
				S[h][w] = '8';
				break;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		cout << S[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout <<(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)? "Yes":"No")<<endl;
  return 0;
}


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

#define ll long long
using namespace std;

const int N = 1e5 + 5;
int n, m, u, v;
vector<int> adj[N], prod[N][2];
bool vis[N];
ll dp[N], dp2[N];

ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

void dfs(int x) {
    vis[x] = true;
    dp[x] = 1;
    prod[x][0].push_back(1);
    prod[x][1].push_back(1);
    vector<int> c;
    for(int y : adj[x]) {
        if(!vis[y]) {
            c.push_back(y);
            dfs(y);
            dp[x] = mod(dp[x] * (1 + dp[y]), m);
            prod[x][0].push_back(dp[x]);
        }
    }
    reverse(c.begin(), c.end());
    ll val = 1;
    for(int y : c) {
        val = mod(val * (1 + dp[y]), m);
        prod[x][1].push_back(val);
    }
    reverse(prod[x][1].begin(), prod[x][1].end());
}
void dfs2(int x) {
    vis[x] = true;
    int cnt = 0;
    dp[x] = mod(dp[x] * dp2[x], m);
    for(int y : adj[x]) {
        if(!vis[y]) {
            cnt++;
            dp2[y] = mod(1 + mod(dp2[x] * prod[x][0][cnt - 1], m) * prod[x][1][cnt], m);
            dfs2(y);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n - 1; i++) {
        cin >> u >> v;
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0);
    fill(vis, vis + N, false);
    dp2[0] = 1;
    dfs2(0);
    for(int i = 0; i < n; i++) {
        cout << dp[i] << "\n";
    }
}

Measured memory_bytes: 29184
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    ll N;
    ll res = 0;
    std::cin >> N;

    vl A(N, 0);
    floop(N)
    {
        std::cin >> A[i];
        if(i > 0)
        {
            if(A[i] < A[i-1])
            {
                res += (A[i-1] - A[i]);
                A[i] = A[i-1];
            }
        }
    }

    print(res);
    return 0;
}

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

int main(){
  int n, m; cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  vector<int> a(n, -1);
  for(int i = 0; i < m; i++){
    cin >> s[i] >> c[i];
    s[i]--;
    if(a[s[i]] == -1 || a[s[i]] == c[i]){
      a[s[i]] = c[i];
    }
    else{
      cout << -1;
      return 0;
    }
  }
  if(n >= 2 && a[0] == 0){
    cout << -1;
    return 0;
  }
  for(int i = 0; i < n; i++)
    if(a[i] == -1){
      if(n >= 2 && i == 0)
        a[i] = 1;
      else
        a[i] = 0;
    }
  int ans = 0;
  int x = 1;
  for(int i = n-1; i >= 0; i--){
    ans += a[i] * x;
    x *= 10;
  }
  cout << ans;
  return 0;
}


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

const int MAX = 500000;
const int mod = 1000000007;

long long fac[MAX]; //i!%mod=fac[i]
long long finv[MAX]; //pow(i!,-1)%mod=finv[i]
long long inv[MAX]; //pow(i,-1)%mod=inv[i]

// テーブルを作る前処理
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long modpow(long long a,int b)
{
	if (b==0)
	{
		return 1LL;
	}
	if (b==1)
	{
		return a%mod;
	}
	long long ans=modpow(a,b/2);
	ans*=ans;
	ans%=mod;
	if (b%2==1)
	{
		ans*=a;
		ans%=mod;
	}
	return ans;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long 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 main(int argc, char const *argv[])
{
	cominit();
	int n;
	long long a,b,c;
	cin>>n>>a>>b>>c;
	long long ans=0LL;
	for (int i = n; i < 2*n; ++i)
	{
		long long tmp=modpow(a,n)*modpow(b,i-n)%mod+modpow(a,i-n)*modpow(b,n)%mod;
		tmp%=mod;
		tmp*=com(i-1,n-1);
		tmp%=mod;
		tmp*=i*100LL;
		tmp%=mod;
		tmp*=modinv(modpow(a+b,i)*(100LL-c)%mod,mod);
		tmp%=mod;
		ans+=tmp;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,mindiv = INT_MAX;
    cin >> n;
    // vi a(n);
    int a;
    rep(i, 0, n){
        cin >> a;
        int cnt=0;
        while (a % 2 == 0){
            cnt++;
            a /= 2;
        }
        mindiv = min(cnt, mindiv);
    }
    cout << mindiv << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        String word = s.next();
        HashSet<Character>hs = new HashSet<>();
        for(int i=0;i<word.length();i++)hs.add(word.charAt(i));
        if(hs.size()==2) System.out.println("Yes");
        else System.out.println("No");
    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25404
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

Mod = 1e+9.to_i + 7

def main(argv)
  n = InputLine.to_i
  a = InputLine.to_ia

  s = [0] * (n + 1)
  n.times{|i| s[i + 1] = (s[i] + a[i]) % Mod}

  t = 0
  n.times do |i|
    p = (a[i] * (s[n] + Mod - s[i + 1])) % Mod
    t = (t + p) % Mod
  end
  puts t.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 31696
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n, m;
	cin >> n >> m;
	vector<string> as(n), bs(m);
	for(int i = 0; i < n; ++i){ cin >> as[i]; }
	for(int j = 0; j < m; ++j){ cin >> bs[j]; }
	for(int y = 0; y + m <= n; ++y)
	for(int x = 0; x + m <= n; ++x){
		bool ok = true;
		for(int i = 0; i < m; ++i){
			if(as[i + y].compare(x, m, bs[i])){
				ok = false;
				break;
			}
		}
		if(ok){
			puts("Yes");
			return;
		}
	}
	puts("No");
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

int a;
int b;
int c;

void input() {
    cin >> a;
    cin >> b;
    cin >> c;
}

int main() {
    input();
    int cnt = 0;
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ld long long double
#define ll long long
#define mod 1000000007
#define scl(x) scanf("%lld",&x)
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}

ll power(ll a,ll b) {
    ll res=1LL;
    while(b>0){
        if(b&1) res = mul(res,a);
        b/=2;
        a = mul(a,a);
    }
    return res%mod;
}

int main(){
   ll n;
   cin >> n;
   ll arr[n];
   ll sum = 0;
   for(ll i=0;i<n;i++) cin >> arr[i];
    for(ll i=0;i<n;i++) {
        for(ll j=i+1;j<n;j++) {
            sum += (arr[i]*arr[j]);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
int main() {
    int n,m,l;
    scanf("%d%d%d", &n, &m, &l);
    long a[n][m], b[m][l];
    for (int i=0; i<n; i++) for (int j=0; j<m; j++) scanf("%ld", &a[i][j]);
    for (int i=0; i<m; i++) for (int j=0; j<l; j++) scanf("%ld", &b[i][j]);
    for (int i=0; i<n; i++) for (int j=0; j<l; j++) {
        long s=0;
        for (int k=0; k<m; k++) {
            s += a[i][k] * b[k][j];
        }
        printf("%ld", s);
        if (j < l - 1) printf(" ");
        else printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
#include <bits/stdc++.h>
using namespace std;
double pi=3.14159265358979323846264338;


bool issqt(long long k){
	if(k<=3)return true;
	long long s=(long long)sqrt(k);
	//cout<<k<<" "<<s<<endl;
	for(long long i=2;i<=s;i++)
		if(k%i==0)return false;
	return true;
}
 
 
int main() {
	double a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v<=w){cout<<"NO"<<endl;return 0;}
	if(fabs(a-b)/(v-w)<=t)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
  return 0;
}



Measured memory_bytes: 3744
parseInt(x) = parse(Int,x)

function main()
	n = parseInt(readline())
	x = parseInt.(split(readline()))
	y = sort(x)
	m1 = y[div(n,2)]
	m2 = y[div(n,2)+1]
	for i in 1:n
		if x[i] <= m1
			println(m2)
		else
			println(m1)
		end
	end
end

main()

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

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
  ll x;
  cin >> x;

  vector<ll> el = {};
  for (ll i = 0; i <= 3000; i++)
  {
    el.push_back(i * i * i * i * i);
  }

  for (ll i = 0; i < el.size(); i++)
  {
    for (ll j = 0; j < el.size(); j++)
    {
      ll ii = i,
         jj = j;
      if (el[i] - el[j] == x)
      {
        cout << ii << " " << jj << endl;
        return 0;
      }
      else if (el[i] + el[j] == x)
      {
        cout << ii << " " << -jj << endl;
        return 0;
      }
      else if (-el[i] - el[j] == x)
      {
        cout << -ii << " " << jj << endl;
        return 0;
      }
      else if (-el[i] + el[j] == x)
      {
        cout << -ii << " " << -jj << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

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

    int dp[55];
    fill(dp, dp + 55, 1e9);
    dp[0] = 0;
    for(int i = 2; i <= 50; i++){
        dp[i] = dp[i - 2] + 380;
        if(i >= 3) dp[i] = min(dp[i], dp[i - 3] + 550);
        if(i >= 5) dp[i] = min(dp[i], dp[i - 5] + 850);
        if(i >= 10) dp[i] = min(dp[i], dp[i - 10] + 1520);
        if(i >= 12) dp[i] = min(dp[i], dp[i - 12] + 1870);
        if(i >= 15) dp[i] = min(dp[i], dp[i - 15] + 2244);
    }

    int n;
    while(cin >> n){
        if(n == 0) break;
        cout << dp[n / 100] << endl;
    }


    return 0;
}


Measured memory_bytes: 3048
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=2020,P=1000000007;
int i,j,k,n,m,ans;
int tm2[N],f[N][N],Jc_[N],Jc[N];
int ksm(int x,int y) {
	int z=1;
	for (;y;y>>=1,x=(ll) x*x%P) if (y&1) z=(ll) z*x%P;
	return z;
}
void pre(int n) {
	int i;
	tm2[0]=1;
	for (i=1;i<=n;i++) tm2[i]=(tm2[i-1]*2)%P;
	Jc[0]=Jc_[0]=1;
	for (i=1;i<=n;i++) Jc[i]=(ll) Jc[i-1]*i%P;
	Jc_[n]=ksm(Jc[n],P-2);
	for (i=n-1;i;i--) Jc_[i]=(ll) Jc_[i+1]*(i+1)%P;
}
int C(int n,int m) {
	if (m>n) return 0;
	return (ll) Jc[n]*Jc_[m]%P*Jc_[n-m]%P;
}
int main() {
	scanf("%d%d",&n,&m);
	pre(n);
	if (n<=2) return puts("1"),0;
	if (m==1) return printf("%d\n",tm2[n-2]),0;
	f[1][0]=1;
	for (i=1;i+1<m;i++) {
		f[i+1][0]=(f[i+1][0]+f[i][0])%P;
		f[i+1][1]=(f[i+1][1]+P-f[i][0])%P;
		f[i+1][2]=(f[i+1][2]+f[i][0])%P;
		f[i+1][i+2]=(f[i+1][i+2]+P-f[i][0])%P;
		for (j=1;j<=i;j++) {
			f[i+1][2]=(f[i+1][2]+f[i][j])%P;
			f[i+1][j+2]=(f[i+1][j+2]+P-f[i][j])%P;
		}
		for (j=1;j<=i+1;j++) f[i+1][j]=(f[i+1][j]+f[i+1][j-1])%P;
	}
	ans=((ll) f[m-1][0]*C(n-1,m-1)+ans)%P;
	for (i=2;i<m;i++) ans=((ll) f[m-1][i]*C(n-m+i-1,n-m)+ans)%P;
	if (m<n) ans=((ll) ans*tm2[n-m-1])%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main(){

  vector<int> a(3);
  rep(i, 3)cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[0] + a[1] << endl;

}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int a, b, c, n;
	cin >> n;
	int dp[2][3] = {0};
	int x = 0, y = 1;
	for(int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		dp[x][0] = max(dp[y][1], dp[y][2])+a;
		dp[x][1] = max(dp[y][0], dp[y][2])+b;
		dp[x][2] = max(dp[y][0], dp[y][1])+c;
		swap(x, y);
	}
	cout << max({dp[y][0], dp[y][1], dp[y][2]}) << '\n';

	return 0;
 }


Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
using namespace std;
long long n, s, a[100005];
int main() {
	int i, t;;
	scanf("%d", &n);
	for(i=1; i<=n; i++) {
		scanf("%d", &a[i]);
		t = min(a[i], a[i-1]);
		s += t;
		a[i] -= t;
		s += a[i]/2;
		a[i] %= 2;
	}
	printf("%lld", s);
	return 0;
}

Measured memory_bytes: 1024
x=int(input())
if 400<=x<=599:
  print(8)
if 600<=x<=799:
  print(7)
if 800<=x<=999:
  print(6)
if 1000<=x<=1199:
  print(5)
if 1200<=x<=1399:
  print(4)
if 1400<=x<=1599:
  print(3)
if 1600<=x<=1799:
  print(2)
if 1800<=x<=1999:
  print(1)


Measured memory_bytes: 61620
N, M = map(int, input().split())
AC = set([])
ans_wa = 0
WA = {}
for i in range(M):
    p, S = input().split()
    if p in AC:
        continue
    if S == "AC":
        AC.add(p)
        if p in WA:
            ans_wa += WA[p]
    elif p in WA:
        WA[p] += 1
    else:
        WA[p] = 1
print(len(AC), ans_wa)


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    lint ans=0;

    FOR(i, 1, n + 1)
    {
        if(i%3==0||i%5==0){
            continue;
        }
        ans += i;
    }

    cout << ans <<"\n";

    return 0;
}

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

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

    double r; cin>>r;
    double ans = 2 * 3.141592 * r;
    cout<<fixed<<setprecision(12)<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3804
import sys
readline = sys.stdin.readline
write = sys.stdout.write

N, Q = map(int, readline().split())
*A, = map(int, readline().split())
X = map(int, readline().split())

ss = [0]; tt = []
v = 0
for a in A:
    v += a
    ss.append(v); tt.append(v)
ss.pop(); tt.append(10**15)

def solve(x):
    t = v = 0
    it = iter(tt).__next__
    nxt = it()-x
    for s, c in enumerate(ss):
        while nxt <= c:
            nxt = it()-x; t += 1
        yield t-s
write("\n".join(map((lambda x: str(sum(x))), map(solve, X))))
write("\n")



Measured memory_bytes: 16860
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}

			int flg = -1;
			int l = -1, r = -1;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				if (s.equals("lu")) l *= -1;
				if (s.equals("ru")) r *= -1;
				if (s.equals("ld")) l *= -1;
				if (s.equals("rd")) r *= -1;
				
				if (l == 1 && r == 1 && flg == -1) {
					cnt++;
					flg *= -1;
				}
				if (l == -1 && r == -1 && flg == 1) {
					cnt++;
					flg *= -1;
				}
			}
			System.out.println(cnt);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26976
#include<stdio.h>
#include<string.h>

int main(void){

    char S[11],T[11],U[11];
    int A,B = 0;

    scanf("%s %s",S,T);
    scanf("%d %d",&A,&B);
    scanf("%s",U);

    if(strcmp(U,S) == 0) A--;
    else B--;

    printf("%d %d",A,B);

    return 0;
}


Measured memory_bytes: 888
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			int s=sc.nextInt();
			if(n==0&&s==0)
				break;
			int ans=0;
			// println("n="+n+",s="+s);
			for(int i=0; i<1<<10; i++){
				if(Integer.bitCount(i)==n){
					int sum=0;
					int b=i;
					// println(Integer.toBinaryString(i));
					for(int k=0; k<10; k++){
						if((b&1)==1)
							sum+=k;
						b>>=1;
					}
					if(sum==s)
						ans++;
				}
			}
			println(ans+"");
		}
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 11000
from collections import defaultdict
d = defaultdict(int)
w = ['']*32
for s in input().split():
    d[s] += 1
    w[len(s)-1] = s
l = sorted(((k, v) for k, v in d.items()), key=lambda x: -x[1])
print(l[0][0], next(s for s in w[::-1] if s))

Measured memory_bytes: 7608
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  REP(i,N) cin >> w[i] >> v[i];
  ll dp[N+10][W+10]={};
  REP2(j,w[0],W+1) dp[0][j] = v[0];
  REP2(i,1,N)REP(j,W+1){
    if(j-w[i]>=0){
      ll tmp = dp[i-1][j-w[i]] + v[i];
      dp[i][j] = max(tmp, dp[i-1][j]);
    }else{
      dp[i][j] = dp[i-1][j];
    }
  }
  cout << dp[N-1][W];
  return 0;
}

Measured memory_bytes: 86272
x = int(input())

min_x = -int(pow(x,0.2))-1
for a in range(x):
    for b in range(min_x,x):
        test = pow(a,5) - pow(b,5)
        if b > 0 and test < x:
            break
        if test == x:
            print(a,b)
            exit()

Measured memory_bytes: 9384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    s = S()
    e = set()
    r = len(s)
    for i in range(r-2,-1,-2):
        if s[:i//2] == s[i//2:i]:
            return i
    return -1


print(main())





Measured memory_bytes: 5460
let () = Scanf.scanf "%d %d\n" @@ fun n x ->
  let ms = Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun m -> m in
  Printf.printf "%d\n" @@ n + (x - Array.fold_left ( + ) 0 ms) / Array.fold_left min max_int ms


Measured memory_bytes: 384
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<int,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
ostream &operator<<(ostream &os, const vector<int> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
#define N 32768
#define maxv 114514
vector<pint> v,v2;
vector<tint> t;
vector<int> gr[maxv],rgr[maxv];
vector<int> vs;
bool sumi[maxv];
int cmp[maxv];
vector<int> pos[25252];
int n;
void dfs(int v){
	sumi[v]=true;
	rep(i,gr[v].size()){
		if(!sumi[gr[v][i]]) dfs(gr[v][i]);
	}
	vs.pb(v);
}
void rdfs(int v,int k){
	sumi[v]=true;cmp[v]=k;
	rep(i,rgr[v].size()){
		if(!sumi[rgr[v][i]]) rdfs(rgr[v][i],k);
	}
}
void scc()
{
	memset(sumi,false,sizeof(sumi));
	vs.clear();
	rep(i,n*2){
		if(!sumi[i]) dfs(i);
	}
	memset(sumi,false,sizeof(sumi));
	//memset(cmp,-1,sizeof(cmp));
	int k=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(!sumi[vs[i]]) rdfs(vs[i],k++);
	}
}
void aedge(int v,int w){
	gr[v].pb(w);
	rgr[w].pb(v);
}
//[a,b)にvから辺を貼る
void query(int a,int b,int v,int k=0,int l=0,int r=N){
	//REP(i,a,b) aedge(v,i+2*n+N-1);return;
	if(r<=a || b<=l) return;
	if(a<=l && r<=b){
		//cout<<k<<endl;
		aedge(v,k+2*n);return;
	}
	query(a,b,v,k*2+1,l,(l+r)/2);
	query(a,b,v,k*2+2,(l+r)/2,r);
}
bool cal(int mi){
	rep(i,maxv-5) gr[i].clear(),rgr[i].clear();
	rep(i,N-1) aedge(2*n+i,2*n+i*2+1),aedge(2*n+i,2*n+i*2+2);
	rep(i,n){
		aedge(pos[i][0],pos[i][1]+2*n+N-1);
		aedge(pos[i][1]+2*n+N-1,pos[i][0]);
		aedge(pos[i][1],pos[i][0]+2*n+N-1);
		aedge(pos[i][0]+2*n+N-1,pos[i][1]);
	}
	rep(i,n*2){
		int l=lower_bound(All(v),mp(v[i].fi-mi+1,-1))-v.begin();
		int r=lower_bound(All(v),mp(v[i].fi+mi,-1))-v.begin();
		//cout<<i<<' '<<l<<' '<<r<<endl;
		//cout<<l<<'q'<<i<<endl;
		query(l,i,i);
		//cout<<i+1<<'q'<<r<<endl;
		query(i+1,r,i);
	}
	scc();
	rep(i,2*n){
		//cout<<cmp[i]<<' '<<cmp[i+2*n+N-1]<<endl;
		if(cmp[i]==cmp[i+2*n+N-1]) return false;
	}
	return true;
}
int main()
{
	int x,y,inf=1001001001;
	cin>>n;
	rep(i,n){
		cin>>x>>y;
		if(x>y) swap(x,y);
		v.pb(mp(x,i));v.pb(mp(y,i));
	}
	sort(All(v));v.pb(mp(inf*2,-1));
	rep(i,2*n) pos[v[i].se].pb(i);
	//rep(i,n) cout<<pos[i]<<endl;
	
	int lo=0,hi=inf;
	//cal(5);
	while(hi>lo){
		int mi=(hi+lo+1)/2;
		if(cal(mi)) lo=mi;else hi=mi-1;
	}
	cout<<lo<<endl;
}


Measured memory_bytes: 24828