akhauriyash/Code-Regression huggingface dataset:
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> s(H, vector<int>(W));
  vector<int> ichigo_in_row(H);
  char tmp;
  for (int i = 0; i < H; i++) {
    int ichigo_cnt = 0;
    for (int j = 0; j < W; j++) {
      cin >> tmp;
      if (tmp == '.')
        s[i][j] = 0;
      else {
        s[i][j] = 1;
        ichigo_cnt++;
      }
    }
    ichigo_in_row[i] = ichigo_cnt;
  }
  vector<vector<int>> ans(H, vector<int>(W, -1));
  int idx = 1;
  for (int i = 0; i < H; i++) {
    int idx_row = 0;
    if (ichigo_in_row[i] == 0) {
      if (i != 0) {
        for (int j = 0; j < W; j++) {
          ans[i][j] = ans[i - 1][j];
        }
        ichigo_in_row[i] = ichigo_in_row[i - 1];
      }
      continue;
    }
    for (int j = 0; j < W; j++) {
      ans[i][j] = idx;
      if (s[i][j] == 1) {
        idx_row++;
        if (idx_row < ichigo_in_row[i]) idx++;
      }
    }
    idx++;
  }

  for (int i = H - 2; i >= 0; i--) {
    if (ichigo_in_row[i] != 0) {
      continue;
    }
    for (int j = 0; j < W; j++) {
      ans[i][j] = ans[i + 1][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << ans[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1e18
 
ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);
 
 
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
 
ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}
 
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;
 
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
 
        // Update y and x
        y = x - q * y;
        x = t;
    }
 
    // Make x positive
    if (x < 0)
       x += m0;
 
    return x;
}
 
void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
/*
ll v[500001], size[500001];
vector<ll>ve(0);
ll fin(ll x){
    //using path compression optimization
    if(x == v[x]){
        return x;
    }
    return v[x] = fin(v[x]);
}
void uni(ll x, ll y){
    x = fin(x);
    y = fin(y);
    if(x == y){
        return ;
    }
    //Using Union by size method, to reduce long chains
    if(size[x] < size[y]){
	size[x]+= size[y];
    	v[y] = x;}
    else{
	size[y]+=size[x];
	v[x]=y;
	}
}
*/
int main()
{
   // ios::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ll n, w;
    cin>>n>>w;
    //memset(dp, 0, sizeof(dp));
    vll p(n), v(n);
    ll sum=0;
    REP(i, 0, n){
        cin>>p[i]>>v[i];
        sum+=v[i];
    }

    vector<ll>dp(sum+1, INF);
    dp[0]=0;
    REP(i, 0, n){
        for(ll j = sum-v[i]; j>=0; j--){
            dp[j+v[i]] = min(dp[j+v[i]], dp[j]+p[i]);
        }
    }
    ll ans=0;
    REP(i, 0, sum+1){
        if(dp[i] <= w){
            ans = max(ans,i);
        }
    }
    cout<<ans;  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>S;
    N = S.size();
    char last = S[0],now;
    ll ans = 1;
    bool two = false;
    reps(i,1,N){
        now = S[i];
        if(two){
            ++ans;
            two = false;
            last = ' ';
        }else{
            if(now == last) {
                two = true;
            }else{
                ++ans;
            }
            last = now;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(M)]
for i in range(1000):
    t = str(i)
    if len(t) != N:
        continue
    flg = True
    for item in data:
        if t[item[0]-1] != str(item[1]):
            flg = False
            break
    if flg:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x;
    cin>>x;
    cout<<(x>=30 ? "Yes" : "No");

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'

using namespace std;
void solve() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; ++i) {
        int t;
        cin >> t;
        sum += t;
    }
    int ans = n - sum;
    if (ans < 0) {
        ans = -1;
    }
    cout << ans << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3644
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
    var n = readLine.split(" ").map(_.toInt)

    while( n(0) != 0 || n(1) != 0) {
      val str1 = "#."*n(1)
      val str2 = ".#"*n(1)

      for(i <- 0 to n(0)-1) {
        if(i%2==0)
          println(str1.take(n(1)))
        else
          println(str2.take(n(1)))
      }
      println()
      n = readLine.split(" ").map(_.toInt)
    }
  }
}

Measured memory_bytes: 44344
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<climits>
using namespace std;
void File(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
template<typename T>bool chkmax(T &_,T __){return _<__ ? (_=__,1) : 0;}
template<typename T>bool chkmin(T &_,T __){return _>__ ? (_=__,1) : 0;}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int i=beg[x];i;i=E[i].last)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define inf INT_MAX
int n,Min=inf;
int cal(int x){
	int ret=0,y=1,cnt=0;
	while(y<=x)y*=10,++cnt;
	while(cnt--){
		y/=10;
		ret+=x/y;
		x%=y;
	}
	return ret;
}
int main(){
	//File();
	scanf("%d",&n);
	REP(i,1,n-1){
		int a=i,b=n-i;
		chkmin(Min,cal(a)+cal(b));
	}
	cout<<Min<<endl;
	return 0;
}


Measured memory_bytes: 256
////   SHAKALAKA BOOM BOOM ////

#include<bits/stdc++.h>

#define ll           long long
#define vi           vector<ll>
#define pb           push_back
#define all(a)       (a).begin(),(a).end()
#define F            first
#define S            second
#define sz(x)        (int)x.size()
#define hell         1000000007
#define endl         '\n'
#define fl(z,a,b)    for(ll z=a;z<b;z++)
#define ifl(i,a,b)   for(ll i=a;i<=b;i++)
#define dfl(i,a,b)   for(ll i=a;i>=b;i--)
#define speed        ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define debug1(x)    cerr << "at line " << __LINE__ << ": " << #x << " = " << (x) << endl
#define debug2(x)    cerr << #x << " = " << (x) << endl
using namespace std;
//=====================
//const int N=1e6;





void solve()
{
        ll n;
        cin>>n;
        vi arr(n+1);
        ifl(i,1,n)
        {
            cin>>arr[i];
        }

        vi dp(n+1);
        dp[1] = 0;
        ifl(i,2,n)
        {
            ll ans  = dp[i-1] + abs(arr[i]-arr[i-1]);
            if(i-2>=1) ans = min(ans,dp[i-2]+abs(arr[i]-arr[i-2]));
            dp[i] = ans;

        }

        cout<< dp[n] << endl;

}



int main()
{
    ll TESTS=1;
    speed;
  //  cin>>TESTS;
    while(TESTS--) solve();
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
        int height;
        int first = 0, second = 0, third = 0;
        for (int i = 0; i < 10; i++) {
                cin >> height;
                if (height > first) {
                        third = second;
                        second = first;
                        first = height;
                } else if (height > second) {
                        third = second;
                        second = height;
                } else if (height > third) {
                        third = height;
                }
        }
        cout << first << endl;
        cout << second << endl;
        cout << third << endl;

        return 0;
}

Measured memory_bytes: 1160
#include<cstdio>

char s[100][100];

int main(void) {
  int h,w;
  scanf("%d%d",&h,&w);
  for(int i=0; i<h; i++)
    scanf("%s",&s[i+1][1]);
  for(int i=0; i<h; i++)
    for(int j=0; j<w; j++) {
      if(s[i+1][j+1]!='.') continue;
      int r='0';
      for(int dx=-1; dx<=1; dx++)
        for(int dy=-1; dy<=1; dy++)
          r+=s[i+1+dy][j+1+dx] == '#';
      s[i+1][j+1]=r;
    }
  for(int i=0;i<h; i++)
  printf("%s\n", &s[i+1][1]);
}

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

int main(){
	ll n,a,b; cin>>n>>a>>b;
	ll ans=(n-2)*(b-a)+1;
	if(ans<0) cout<<0<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0;
    rep(i, n) {
        r += s[i] == 'R';
    }
    int cnt = 0;
    rep(i, r) {
        if (s[i] == 'W') cnt++;
    }
    cout << cnt << endl;
}

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

Measured memory_bytes: 3736
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+2;
int n,m;
int a[maxn],d[maxn],res[maxn],tmp[maxn];
LL k;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<n;i++) d[i]=res[i]=i;
	scanf("%d%lld",&m,&k);
	for (int i=1;i<=m;i++){
		int x;
		scanf("%d",&x);
		swap(d[x-1],d[x]);
	}
	while (k){
		if (k&1) for (int i=1;i<n;i++) res[i]=d[res[i]];
		for (int i=1;i<n;i++) tmp[i]=d[d[i]];
		memcpy(d,tmp,n<<2);
		k>>=1;
	}
	LL ans=a[1];
	for (int i=1;i<=n;i++){
		printf("%lld.0\n",ans);
		ans+=a[res[i]+1]-a[res[i]];
	}
	return 0;
}

Measured memory_bytes: 2944
import sys
from collections import deque

input = sys.stdin.readline


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    C = list(map(int, input().split()))
    C.sort(reverse=True)

    M = sum(C[1:])
    d = [0] * N
    i = 0
    queue = deque([(i, -1)])
    while queue:
        u, p = queue.popleft()
        d[u] = C[i]
        i += 1
        for v in G[u]:
            if v == p: continue
            queue.append((v, u))

    print(M)
    print(" ".join(map(str, d)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12156
fun main(args: Array<String>) = abc157b()

fun abc157b() {
    val aList = (1..3).map { readLine()!!.split(' ').map { it.toInt() } }
    val n = readLine()!!.toInt()
    val bList = (1..n).map { readLine()!!.toInt() }

    val list = Array(3) { BooleanArray(3) }

    bList.forEach { b ->
        for ((index, row) in aList.withIndex()) {
            for ((index2, a) in row.withIndex()) {
                if (a == b) list[index][index2] = true
            }
        }
    }

    for (i in 0..2) {
        if (list[i].all { it }) return println("Yes")
    }

    if (list.all { it[0] } || list.all { it[1] } || list.all { it[2] }) return println("Yes")

    if ((list[0][0] && list[1][1] && list[2][2]) || (list[0][2] && list[1][1] && list[2][0])) return println("Yes")

    println("No")
}


Measured memory_bytes: 38156
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

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

    cout << (n-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N;
  cin >> N;

  vector<int> cnt;
  ll i;
  for(i=2;i*i<=N;i++){
    int tmp=0;
    while(N%i==0){
      N/=i;
      tmp++;
    }
    if(tmp==0)  continue;
    cnt.p_b(tmp);
  }
  if(N!=1)  cnt.p_b(1);
  //for(int i=0;i<sz(cnt);i++)  cout << cnt.at(i) << endl;

  int ans=0;
  for(int i=0;i<sz(cnt);i++){
    int now=1;
    while(1){
      cnt.at(i)-=now;
      if(cnt.at(i)<0) break;
      ans++;
      now++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
from __future__ import print_function
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

cnt=0
S=list(input())
# eprint(S)

L=list()
L.append(S.pop())
while len(S)!=0:
    if S[-1]==L[-1]: # SのfrontとLのfrontが0と0とか一致しちゃった時だから，消せない．次のSのfrontを見よう 
        L.append( S.pop() )
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))
    else: # SのfrontとLのfrontが0と1となっている場合．消す．
        S.pop()
        L.pop()
        if L==[] and S!=[]:
            L.append(S.pop())
        cnt=cnt+2
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))

print(cnt)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#


Measured memory_bytes: 50032
#include<stdio.h>
long long gcd(long long a,long long b)
{  
    int temp;  
    if(a < b)
	{  
      temp = a;  
      a = b;  
      b = temp;  
    }    
    if(a%b == 0){  
        return b;    
    }
	else
	{    
        return gcd(b,a%b);    
    }    
} 
int main()
{
	int n;
	long long  gcd(long long a,long long b);
    long long  c[109],sum;
	while(~scanf("%d",&n))
	{
		sum=0;
		for(int i=0;i<n;i++)
		scanf("%lld",&c[i]);
		while(n==1) 
		{
		printf("%lld\n",c[0]);
		return 0;	
		}
			for(int i=0;i<n-1;i++)
			{	
				
				sum=(c[i]/gcd(c[i],c[i+1]))*c[i+1];
				c[i+1]=sum;
			}
			printf("%lld\n",sum);
	}
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	n,m=map(int,input().split())
	li=[[] for _ in range(n+1)]
	for i in range(m):
		l,r,d=map(int,input().split())
		li[l].append((r,d))
		li[r].append((l,-d))
	
	q=deque()
	a=[None]*(n+1)

	for i in range(1,n+1):
		if a[i]==None:
			q=[i]
			a[i]=0
			while q:
				now=q.pop()
				for r,d in li[now]:
					if a[r]==None:
						a[r] = a[now] + d
						q.append(r)
					else:
						if a[r]-a[now]!=d:
							print("No")
							exit(0)
						else:
							continue
					
	print("Yes")
	
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 66204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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

// ---------------------
#define INF 922337203685477580
#define IINF (1<<21)
typedef long long ll;

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

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

  if (x < y) {
    swap(x, y);
  }

  cout << gcd(x, y) << endl;
  return 0;
}

Measured memory_bytes: 3116
#include<stdio.h>
int main()
{
    int M,N;
    scanf("%d%d",&M,&N);

    int a,b,c;

    if(M<2)
        a=0;
    if(N<2)
        b=0;

    a=M*(M-1)/2;
    b=N*(N-1)/2;

    c=a+b;
    printf("%d",c);

    return 0;
}


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

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split().ToArray();
        int n = int.Parse(s[0]);
        int m = int.Parse(s[1]);

        List<City> cities = new List<City>();

        for (int i = 0; i < m; i++)
        {
            s = Console.ReadLine().Split().ToArray();
            cities.Add(new City() { n = i, p = int.Parse(s[0]), y = int.Parse(s[1]) });
        }

        int[] pref = new int[100001];

        cities.Sort(CompareYear);

        for (int i = 0; i < m; i++)
        {
            pref[cities[i].p]++;
            cities[i].l = string.Format("{0:D6}", cities[i].p) + string.Format("{0:D6}", pref[cities[i].p]);
        }

        cities.Sort(CompareNum);

        foreach (var item in cities)
        {
            Console.WriteLine(item.l);
        }
    }

    static int CompareYear(City a, City b)
    {
        return a.y - b.y;
    }

    static int CompareNum(City a, City b)
    {
        return a.n - b.n;
    }
}

class City
{
    public int p;
    public int y;
    public int n;
    public string l;
}

Measured memory_bytes: 29632
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  for (auto &i : s) {
    if (i == '9') {
      cout << "Yes" << '\n';
      return;
    }
  }
  cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3600
#include<iostream>
using namespace std;
#define N 1000
int main(void)
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int num;
	cin >> num;
	if (num < N)
		cout << N - num;
	else
	{
		if (num % N != 0)
			cout << N - num % N;
		else
			cout << 0;
	}
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

class B
{
	static void Main()
	{
		Console.ReadLine();
		var s = Console.ReadLine();
		var k = int.Parse(Console.ReadLine()) - 1;
		Console.WriteLine(new string(s.Select(c => c == s[k] ? c : '*').ToArray()));
	}
}


Measured memory_bytes: 13268
#! ruby -Ku
def f a, r, n, m
	cl = a.map{|l| l.first}.group_by{|x|x}.map{|k, v| [k, v.size]}
	res = cl.max_by{|k, v| v}[1]
#	p a
#	p res
	return res if r==1
	return res if res == (n + r - 1) / r
	
	rl = cl.select{|k, v| v==res}.map{|k, v| k}
#	p rl
	STDERR.puts "運試し"
	[rl.sample].each{|rt|
		a2 = a.map{|l| l.reject{|x| x==rt}}
		mmm = f(a2, r-1, n, m)
		res = mmm if mmm<res
	}
	return res
end
 
n, m = gets.split.map(&:to_i)
a = n.times.map{gets.split.map(&:to_i)}
 
r = f(a, m, n, m)
puts r

Measured memory_bytes: 143356
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int s;
  int score;
  s=0;
  score=0;
  for(int i=0;i<3;i++){
   cin>>s;
    score+=s;
    s=0;
  }
  if(score>=22){
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }
  
  return 0;
}

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

#define ll long long

int main()
{
    string S,T;
    cin>>S>>T;
    ll cnt=0;
    for(ll i=0;i<(ll)S.size();i++)
    {
        if(S[i] != T[i])cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3852
a, b, c = map(int, input().split())
ans = 0
if a == b and b == c:
    if a % 2 == 0:
        print(-1)
    else:
        print(0)
else:
    while True:
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            tempa = b // 2 + c // 2
            tempb = c // 2 + a // 2
            tempc = a // 2 + b // 2
            a = tempa
            b = tempb
            c = tempc
            ans += 1
        else:
            break
    print(ans)

Measured memory_bytes: 3064
def sumd(x):
  s=0
  while x>0:
    t=str(x)
    s+=int(t[-1])
    x//=10
  return s

n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  if a<=sumd(i)<=b:
    ans+=i
print(ans)



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        boolean check = false;
        int x, y = 0, z = 0;
        lavel:
        for (x = 0; N >= x; x++) {
            for (y = 0; N >= y; y++) {
                z = N - (x + y);
                if (z < 0) {
                    continue;
                }
                if (x * 10000 + y * 5000 + 1000 * z == Y && x + y + z == N) {
                    check = true;
                    break lavel;
                }

            }
        }
        if (check == true) {
            System.out.print(x + " ");
            System.out.print(y + " ");
            System.out.println(z + " ");

        } else {
            System.out.println("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <math.h>

int max(a,b){
    if(a > b) return a;
    else      return b;
}

int min(a,b){
    if(a < b) return a;
    else      return b;
}


int main(int argc,char *args[]){
    int i,a,b;
    for(i=0;;i++){
        scanf("%d%d",&a,&b);
        if(a==0 && b==0) break;
        printf("%d %d\n",min(a,b),max(a,b));
    }
    return 0;
}



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

int main(){
	int n;
	int m = 100000;
	cin >> n;

	for(int i = 0; i < n; ++i){
		m = (m*1.05+999)/1000;
		m = m*1000;
	}
	cout << m << '\n';
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main()
{
	int s, t, u, v;
	string str;
	
	while(cin>>s>>t && s && t){
		set<int> st;
		while(t--){
			cin >> str >> u >> v;
			if(str == "xy"){
				for(int i = 1; i <= s; i++){
					st.insert((u+s*(v-1)+s*s*(i-1)));
				}
			} else if(str == "xz"){
				for(int i = 1; i <= s; i++){
					st.insert((u+s*(i-1)+s*s*(v-1)));
				}
			} else {
				for(int i = 1; i <= s; i++){
					st.insert((i+s*(u-1)+s*s*(v-1)));
				}
			}
		}
		cout << (s*s*s-st.size()) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
using P = pair<double, double>;

double d(P i, P j) {
  return sqrt(pow(i.first - j.first, 2) + pow(i.second - j.second, 2));
}

int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  double ans = 1e5;
  rep(i, n - 1) rep2(j, i + 1, n) {
    P o;
    o.first = (p[i].first + p[j].first) / 2;
    o.second = (p[i].second + p[j].second) / 2;
    double r = 0;
    rep(x, n) r = max(r, d(o, p[x]));
    ans = min(ans, r);
  }
  rep(i, n - 2) rep2(j, i + 1, n - 1) rep2(k, j + 1, n) {
    double a = d(p[j], p[k]), b = d(p[i], p[k]), c = d(p[i], p[j]);
    if(-a + b + c < 1e-9 || a - b + c < 1e-9 || a + b - c < 1e-9) continue;
    P o;
    double num1 = a * a * (b * b + c * c - a * a);
    double num2 = b * b * (c * c + a * a - b * b);
    double num3 = c * c * (a * a + b * b - c * c);
    o.first = (num1 * p[i].first + num2 * p[j].first + num3 * p[k].first) /
              (num1 + num2 + num3);
    o.second = (num1 * p[i].second + num2 * p[j].second + num3 * p[k].second) /
               (num1 + num2 + num3);
    double r = 0;
    rep(x, n) r = max(r, d(o, p[x]));
    ans = min(ans, r);
  }
  printf("%.18f\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
  string s; cin>>s;
  if(s=="Sunny") cout<<"Cloudy"<<endl;
  else if(s=="Cloudy") cout<<"Rainy"<<endl;
  else if(s=="Rainy") cout<<"Sunny"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int num=0;
    int i=a;
    for(i;i<=b;i++)
    {
       if((i%10==(i/10000))&&(i/10)%10==(i/1000)%10)
       {
           num++;
       }
    }
    printf("%d",num);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	char a=s[0], b;
	int cnt_a = 0;
	int cnt_b = 0;
	for (int i = 0;i < 4;i++) {
		if (a == s[i]) {
			cnt_a++;
		}
		else b = s[i];
	}
	for (int i = 0;i < 4;i++) {
		if (b == s[i]) {
			cnt_b++;
		}
	}
	if (cnt_a == 2 && cnt_b == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <functional>

#define FOR( i, l, r) for(int i = (l)    ; i <  (r); i++)
#define FOR1(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define REV( i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define REV1(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define INC( i, n) FOR( i, 0, n)
#define INC1(i, n) FOR1(i, 1, n)
#define DEC( i, n) REV( i, 0, n)
#define DEC1(i, n) REV1(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int k, t, a[100];

int main() {
	scanf("%d%d", &k, &t);
	INC(i, t) { scanf("%d", &a[i]); }
	
	std::sort(a, a + t, std::greater<int>());
	int ans;
	if(k % 2 == 0) {
		if(a[0] <= k / 2) { ans = 0; }
		else { ans = 2 * (a[0] - k / 2) - 1; }
	} else {
		if(a[0] <= (k + 1) / 2) { ans = 0; }
		else { ans = 2 * (a[0] - (k + 1) / 2); }
	}
	
	printf("%d\n", ans);
		
	return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;

int main(){
	int x;	cin >> x;
	int ans = 0;

	ans += x / 500 * 1000;
	x -= x / 500 * 500;
	ans += x / 5 * 5;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
using System;

class Program
{
    static void Main(string[] args) {
        var ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));
        //var ret = process("4");

        Console.WriteLine(ret);
        //Console.ReadLine();
    }

    static string process(string input) {
        return process(new System.IO.StringReader(input));
    }

    static string process(System.IO.TextReader input) {
        int a  = int.Parse(input.ReadLine());
        
        return (3*a*a).ToString();
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    vector<ll> v(4);
    cin >> v;
    
    ll ans = -INF;
    rep(i, 2) rep3(j, 2, 4) chmax(ans, v[i] * v[j]);
    cout << ans << endl;
}


Measured memory_bytes: 3652
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from collections import deque

h,w = map(int,readline().split())
ch,cw = map(int,readline().split())
dh,dw = map(int,readline().split())
s = read().split()

ch -= 1
cw -= 1
dh -= 1
dw -= 1

wall = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if(s[i][j] == '#'):
            wall[i][j] = 1

inf = 10**10
cost = [[inf] * w for _ in range(h)]
cost[ch][cw]=0
d = deque()
d.append((0,ch,cw))

while(d):
    ci,xi,yi = d.popleft()
    if(cost[xi][yi] > ci):
        continue

    for dx in range(-2,3):
        xj = xi+dx
        if(xj<0)|(xj>=h):
            continue
        for dy in range(-2,3):
            yj = yi+dy
            # print(xi,yi,xj,yj)
            if(yj<0)|(yj>=w):
                continue
            if(xi==xj)&(yi==yj):
                continue
            if(wall[xj][yj]==1):
                continue
            if(abs(xi-xj)+abs(yi-yj)==1):
                if(cost[xj][yj] > ci):
                    cost[xj][yj] = ci
                    d.appendleft((ci,xj,yj))
            else:
                if(cost[xj][yj] > ci+1):
                    cost[xj][yj] = ci+1
                    d.append((ci+1,xj,yj))

if(cost[dh][dw] == inf):
    print(-1)
else:
    print(cost[dh][dw])

Measured memory_bytes: 112488
#include <stdio.h>

int main(void)
{
	int n;
	float h;
	int i, j;
	int ans[6];
	
	scanf("%d", &n);
	for (i = 0; i < 6; i++) {
		ans[i] = 0;
	}
	for (i = 0; i < n; i++) {
		scanf("%f", &h);
		if (h >= 185) {
			ans[5]++;
		}
		else if (180 <= h && h < 185) {
			ans[4]++;
		}
		else if (175 <= h && h < 180) {
			ans[3]++;
		}
		else if (170 <= h && h < 175) {
			ans[2]++;
		}
		else if (165 <= h && h < 170) {
			ans[1]++;
		}
		else {
			ans[0]++;
		}
	}
	for (i = 0; i < 6; i++) {
		printf("%d:", i + 1);
		for (j = 0; j < ans[i]; j++) {
			printf("*");
		}
		puts("");
	}
	return (0);
}

Measured memory_bytes: 644
#include <iostream>
using namespace std;
 
int main()
{
      long long int n,flag=0,i,sum=0;
      cin>>n;
      for(i=1;i<=n;i++)
      {
            if(i%3!=0&&i%5!=0)
            sum+=i;
            
      }
      cout<<sum;
 
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
using namespace std;
const int maxn=1e5+5;
const int mo=1e9+7;

long long a[maxn],n,m;

int main()
{
    a[1]=1;
    for(long long i=2;i<maxn;i++)
        a[i]=(a[i-1]*i)%mo;
    cin>>n>>m;
    if(n==m)
		cout<<(a[n]*a[n]*2)%mo;
    else if(abs(n-m)==1)
		cout<<(a[n]*a[m])%mo;
    else cout<<0;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> t(N+1);
    vector<int> x(N+1);
    vector<int> y(N+1);
    t.at(0) = 0;
    x.at(0) = 0;
    y.at(0) = 0;
    for (int i = 1; i <= N; i++) cin >> t.at(i) >> x.at(i) >> y.at(i);

    bool can = true;

    for (int i = 1; i <= N; i++) {
        int dt = t.at(i) - t.at(i - 1);
        int dist = abs(x.at(i) - x.at(i-1)) + abs(y.at(i) - y.at(i-1));
        if (dt < dist) can = false;
        if (dist %2 != dt %2) can = false;

    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int ans[250010];
int main(){
	int n;cin>>n;
	vector<P> v;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		v.push_back(P(x,i));
	}
	sort(all(v));
	int nn=n*n;
	int c[510];
	bool f=false;
	int idx=1;
	for(int i=1;i<=n;i++){
		c[i]=n;
	}
	for(int i=0;i<v.size();i++){
		int x=v[i].first;int p=v[i].second;
		ans[x]=p;
		c[p]--;
		for(int j=idx;j<x;j++){
			if(c[p]==n-p){
				break;
			}
			if(ans[j]){
				continue;
			}
			ans[j]=p;
			c[p]--;
			idx++;
		}
		if(c[p]!=n-p)f=true;
		if(f)break;
	}
	idx=1;
	for(int i=0;i<v.size();i++){
		int p=v[i].second;int x=v[i].first;
		for(int j=idx;j<=nn;j++){
			if(c[p]==0){
				break;
			}
			if(ans[j]){
				continue;
			}
			if(j<x){
				f=true;
				break;
			}
			ans[j]=p;
			c[p]--;
			idx++;
		}
	}
	if(f){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
		for(int i=1;i<=nn;i++){	
			cout<<ans[i];
			if(nn-i){
				cout<<" ";
			}
		}
		cout<<endl;
	}
    return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
/*
Exhaustive Search
2019. 4/30
*/

int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i > n) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main() {
    int q, M ,i;

    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int main() {
    long n,k;
    cin >> n >> k;
    long h[n];
    long sum = 0;
    for(int i=0; i < n; i++){
        cin >> h[i];
    }
    sort(h, h + SIZE_OF_ARRAY(h));
    for(int i=0; i < n-k; i++){
        sum += h[i];
    }
    cout << sum << endl;
    
}

Measured memory_bytes: 1792
N, W = map(int, input().split())
item = [[0]*2 for _ in range(N+1)]

for i in range(1, N+1):
    item[i][0], item[i][1] = map(int, input().split())

DP = [[0]*(W+1) for _ in range(N+1)]

for i in range(1, N+1):
    for w in range(0, W+1):
        DP[i][w] = DP[i-1][w]
        if w >= item[i][0]:
            DP[i][w] = max(DP[i][w], DP[i-1][w - item[i][0]] + item[i][1])

print(DP[N][W])

Measured memory_bytes: 147012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll ans = n;
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  ll tot = 0;
  ll cnt = 0;
  for(int i=0;i<n-1;i++) {
    tot += a[i];
    cnt++;
    if(2 * tot <a[i+1]) {
      ans -= cnt;
      cnt = 0;
    }
  }

  cout << ans << endl;
}


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

int main(){
  string sa,sb,sc;
  queue<char> a, b, c;
  cin >> sa >> sb >> sc;
  int i;
  for(i=0;i<sa.size();i++) a.push(sa[i]);
  for(i=0;i<sb.size();i++) b.push(sb[i]);
  for(i=0;i<sc.size();i++) c.push(sc[i]);
  int t=0;
  while(1){
    if(t==0){
      if(a.empty()){
        cout << 'A' << endl;
        return 0;
      }
      t=a.front() - 'a';
      a.pop();
    }else if(t==1){
      if(b.empty()){
        cout << 'B' << endl;
        return 0;
      }
      t=b.front() - 'a';
      b.pop();
    }else {
      if(c.empty()){
        cout << 'C' << endl;
        return 0;
      }
      t=c.front() - 'a';
      c.pop();
    }
  }
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val s = read()

    val tommorrow = when(s) {
        "Sunny" -> "Cloudy"
        "Cloudy" -> "Rainy"
        else -> "Sunny"
    }

    println(tommorrow)

    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 29924
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);


long s;

long MAX =  1e18;
long sqMAX = 1e9;

int main(){
    scanf("%ld", &s);
    long k = (long)sqrt(s)+1;
    //printf("%ld %ld\n", k, k*k);
    if(s == MAX){
        printf("0 0 %ld 0 0 %ld\n", sqMAX, sqMAX);
    }else{
        printf("0 0 %ld %ld %ld %ld\n", 1l, k, k, (k*k-s));
    }
    return 0;
}


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

int main() {
	int q;cin>>q;
	list<int> li;
	auto it = li.end();

	auto insert = [&](int x){
		// std::list::insertは直前に挿入するので, その要素にポインタを持っていくためには--itが必要
		li.insert(it,x);
		--it;
	};

	auto move = [&](int d){
	  while(d<0) --it,++d;
		while(d>0) ++it,--d;
	};

	auto erase = [&](){
		it = li.erase(it);
	};
	
	while(q--){
		int query;cin>>query;
		if(query==0){
			// insert
			int x;cin>>x;
			insert(x);
		}else if(query==1){
			// move
			int d;cin>>d;
			move(d);
		}else{
			// erase
			erase();
		}
	}

	for(auto &&lj: li){
		cout<<lj<<endl;
	}
  return 0;
}



Measured memory_bytes: 18596
n=int(input())
w=list(map(int,input().split()))

mini = abs(sum(w[0:1])-sum(w[1:]))

for k in range(1,n):
  sumL = sum(w[0:k])
  sumR = sum(w[k:])
  diff = abs(sumL-sumR)
  if mini > diff:
    mini = diff
print(mini)
  

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;

int main(){
    
    int N;cin>>N;
    if(N==3) cout<<"2 5 63"<<endl;
    else if(N==4) cout<<"2 5 20 63"<<endl;
    else{
        if(N<=15002){
            cout<<"3 9";
            if((N-2)%3==1){
                for(int i=1;i<=N-4;i++){
                    cout<<" "<<i*2;
                }
                cout<<" "<<(N-2)*2<<" "<<(N-1)*2<<endl;
            }else{
                for(int i=1;i<=N-2;i++){
                    cout<<" "<<i*2;
                }
                cout<<endl;
            }
        }else{
            if(N%2==0){
                for(int i=1;i<=15000;i++){
                    if(i>=2) cout<<" ";
                    cout<<i*2;
                }
                for(int i=1;i<=N-15000;i++){
                    cout<<" "<<i*6-3;
                }
                cout<<endl;
            }else{
                cout<<"2 4";
                for(int i=4;i<=15000;i++){
                    cout<<" "<<i*2;
                }
                for(int i=1;i<=N-14999;i++){
                    cout<<" "<<i*6-3;
                }
                cout<<endl;
            }
        }
    }
}


Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int MOD = 998244353;

inline int add(int a, int b)
{
    a += b;
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
    return a;
}

inline int mul(int a, int b)
{
    return (a * (ll) b) % MOD;
}

inline int bin(int a, int n)
{
    int res = 1;
    while (n)
    {
        if (n % 2 == 0)
        {
            a = mul(a, a);
            n /= 2;
        }
        else
        {
            res = mul(res, a);
            n--;
        }
    }
    return res;
}

inline int rev(int x)
{
    return bin(x, MOD - 2);
}

const int N = 6e5 + 7;

int fact[N];
int rfact[N];

int C(int n, int k)
{
    return mul(fact[n], mul(rfact[k], rfact[n - k]));
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    for (int i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
    rfact[N - 1] = rev(fact[N - 1]);
    for (int i = N - 2; i >= 0; i--)
    {
        rfact[i] = mul(rfact[i + 1], i + 1);
    }
    int n, a, b;
    cin >> n >> a >> b;
    ll k;
    cin >> k;
    int ans = 0;
    for (int r = 0; r <= n; r++)
    {
        ll rest = k - a * (ll) r;
        if (rest % b == 0 && rest / b <= n && rest / b >= 0)
        {
            ans = add(ans, mul(C(n, r), C(n, rest / b)));
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
n = int(input())
f = [int("".join(input().split()),base=2) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
ans = -10**10

for i in range(1,1<<10):
  profit = 0
  for j in range(n):
    cnt = bin(i&f[j]).count("1")
    profit += p[j][cnt]
  ans = max(ans,profit)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e18+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=1000001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
string s;
ll dp[10001][100][2],k;
ll solve(ll pos,ll mo,ll st)
{
    if(pos==s.size())
    {
      return (mo==0);

    }
    if(dp[pos][mo][st]!=-1)
      return dp[pos][mo][st];
    ll lim=s[pos]-'0';
    if(st==0)
      lim=9;
    ll ans=0;
    for(int i=0;i<=lim;i++)
    {
      int str=st;
      if(i<lim)
        str=0;
      ans=(ans+solve(pos+1,(mo+i)%k,str))%mod;
    }
    dp[pos][mo][st]=ans;
    return ans;
}
int main()
{
   
   fastio;
   int t;
   ll n,i,j,l;
   cin>>s>>k;
    memset(dp,-1,sizeof(dp));
    j=(solve(0,0,1)-1+mod)%mod;
   cout<<j;
   
}

Measured memory_bytes: 20080