akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
using Pii = pair<int, int>;

int cost(Pii a, Pii b) {
  return abs(a.first-b.first) + abs(a.second-b.second);
}

signed main() {
  int H, W, D;
  cin >> H >> W >> D;

  int A[H][W];
  Pii P[H*W+1];
  vector<int> cum(H*W+1, 0);
  REP(i, H) REP(j, W) {
    cin >> A[i][j];
    P[A[i][j]] = Pii(i, j);
  }

  for ( int i = D+1; i <= H*W; i++ ) {
    cum[i] = cum[i-D] + cost(P[i], P[i-D]);
  }

  int Q;
  cin >> Q;
  while ( Q-- ) {
    int l, r;
    cin >> l >> r;
    cout << cum[r] - cum[l] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<ll,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  string s; cin >> s;
  int a = 0,b = 0;
  for(int i = 0; i < 2; i++){
    a *= 10;
    a += s[i] - '0';
  }
  for(int i = 2; i < 4; i++){
    b *= 10;
    b += s[i] - '0';
  }
  if(0 < a && a <= 12){
    if(0 < b && b <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }else{
    if(0 < b && b <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>

typedef unsigned long long ll;

using namespace std;

int main() {
    // your code goes here
    ll n;
    ll  x ,sum;

    cin>>n;

    unordered_map<int,int> fre;

    while(n--){
        cin>>x;
        sum += x;
        fre[x]++;
    }


    ll q;
    cin>>q;

    ll a, b;

    for(int i = 0 ; i < q ; i++){

        cin>>a>>b;

        //all a's became b's so?
        fre[b] += fre[a];

        sum += fre[a] * (b - a);// these many changes

        fre[a] = 0; // nice!

        cout<<sum<<"\n";

    }

    return 0;
}


Measured memory_bytes: 6956
def ex(x, y):
    if x > y:
        tmp = x
        x = y
        y = tmp

    return x, y

def ex2num():
    r1, r2 = input().split(" ")
    r1 = int(r1)
    r2 = int(r2)
    while (0 != r1) or (0 != r2):
        r1, r2 = ex(r1, r2)
        print(r1, r2)
        r1, r2 = input().split(" ")
        r1 = int(r1)
        r2 = int(r2)

    return 0

if __name__ == "__main__":
    ret = ex2num()


Measured memory_bytes: 5620
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
	int N;
	cin >> N;
	long nums[N];
	long first_sum = 0, second_sum = 0;
	for(int i = 0; i < N; i++){
		cin >> nums[i];
		second_sum += nums[i];
	}
	long ans = 1e18;
	for(int i = 0; i < N - 1; i++){
		first_sum += nums[i];
		second_sum -= nums[i];
		ans = min(ans, abs(first_sum - second_sum));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
class a{
public:
    int x{};
    int y{};
    char a{};
    long long int b{};
    string c{};
};
bool com(class a x,class a y){
    if(x.x!=y.x)
        return x.x<y.x;
    else if(x.y!=y.y)
        return x.y<y.y;
    else if(x.a!=y.a)
        return x.a<y.a;
    else if(x.b!=y.b)
        return x.b<y.b;
    else return x.c<y.c;
}
int main() {
    int n;cin>>n;
    //int p[100000][2];
    auto *p=new class a [n];
    for (int i = 0; i < n; ++i) {
        cin>>p[i].x>>p[i].y>>p[i].a>>p[i].b>>p[i].c;
    }
    sort(p+0,p+n,com);
    for (int i = 0; i < n; ++i) {
        cout<<p[i].x<<" "<<p[i].y<<" "<<p[i].a<<" "<<p[i].b<<" "<<p[i].c<<endl;
    }
    return 0;
}



Measured memory_bytes: 12452
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;
Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x=x->l;
    }
    else {
      x=x->r;
    }
  }
  z->p = y;
  if(y == NIL){
    root = z;
  }
  else {
    if(z->key < y->key){
      y->l = z;
    }
    else {
      y->r = z;
    }
  }
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u->r);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
  }
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf(" %s",com);
    if(com[0] == 'i'){
      scanf(" %d",&x);
      insert(x);
    }
    else if (com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}




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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll A[300010];
ll X[65];
ll ans;
int main(){
	cin >> N;
	REP(i,0,N){
		cin >> A[i];
	}
	REP(i,0,N){
		REP(j,0,62){
			X[j] += ((1LL << j) & A[i]) > 0;
		}
	}
	ll two = 1;
	REP(j,0,62){
		ll num = X[j] * (N - X[j]);
		num %= mod;
		num *= two;
		num %= mod;
		ans += num;
		ans %= mod;
		two *= 2;
		two %= mod;
	}
	p(ans);
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22) cout << "bust";
    else cout << "win";
    return 0;
}


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

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=[]

  for i in range(n):
    a,b=LS()
    l.append([a,-int(b),i+1])

  l=sorted(l,key=lambda x:(x[0],x[1]))

  for x in l:
    print(x[2])

main()
# print(main())


Measured memory_bytes: 6820
n,m,x = map(int,input().split())
costlst = []
scorelst = []
ans = float("inf")
for _ in range(n):
    cost,*score = map(int,input().split())
    costlst.append(cost)
    scorelst.append(score)
for i in range(2**n):
    cost = 0
    defaultscore = [0]*m
    for j in range(n):
        if (i>>j)&1:
            cost += costlst[j]
            for k in range(m):
                defaultscore[k] += scorelst[j][k]
    if all([defaultscore[p] >= x for p in range(m)]):
            ans = min(ans,cost)
        
            
                
                
                 
print(ans if ans != float("inf") else "-1")            
    

Measured memory_bytes: 9224
#include <iostream>

using namespace std;

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

typedef long long ll;

int main() {
  string s;
  cin >> s;
  int n = s.size(), a = 0, b = 1, r[2019];
  rep(i,2019) r[i] = 0;
  rep(i,n) {
    a = (a + (s[n-1-i] - '0') * b) % 2019;
    b = (b * 10) % 2019;
    r[a]++;
  }
  ll res = r[0];
  rep(i,2019) res += r[i] * (r[i] - 1) / 2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3324
using System;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Measure.Run();
        }
    }
    public class Measure
    {
        public Measure()
        {

        }
        public static void Run()
        {
            string s = Console.ReadLine();
            if (s.Length == 2) Console.WriteLine(s);
            else
            {
                for (int i = s.Length - 1; i >= 0; i--)
                {
                    Console.Write(s[i]);
                }
                Console.Write("\n");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()

using ll = long long;

int main () {
  int a[3];
  rep(i, 3) cin >> a[i];
  
  cout << (a[0] <= a[2] && a[2] <= a[1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    int n, x;
    cin >> n >> x;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    int count = 0;
    rep(i, n) {
        if(i != n - 1) {
            if(x >= a[i]) {
                count++;
                x = x - a[i];
            }else{
                break;
            }
        }else{
            if(x==a[i])
                count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define hoge cout << hoge << endl;
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,f,g,h,w;
ll x[1000005],y[1000005],z[1000005];
ll dp[8000][6000];
bool flag,dame;

int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
		ans += x[i];
	}
	sort(x,x+n);
	ans -= x[n-1]/2;
	p(ans);
	return 0;
}

Measured memory_bytes: 26880
import math
import itertools

n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
rng = [i for i in range(n)]
ans = 0
for l in itertools.permutations(rng):
    t = 0
    for e, k in enumerate(l):
        if e==0:
            x,y = xy[k][0], xy[k][1]
        nx, ny = xy[k][0], xy[k][1]
        t += ((nx-x)**2 + (ny-y)**2)**0.5
        x,y = nx, ny
    ans += t
print(ans/math.factorial(n))

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		byte a = sc.nextByte();
		for (int l=0; l<a; l++){
			byte gx=sc.nextByte();
			byte gy=sc.nextByte();
			byte No [][] = new byte [gx+1][gy+1];
			byte b = sc.nextByte();
			for (int k=0; k<b; k++){
				byte x1=sc.nextByte();
				byte y1=sc.nextByte();
				byte x2=sc.nextByte();
				byte y2=sc.nextByte();
				
				if (x1 == x2) {
					No [x1][(Math.max(y1, y2))]+=1;
				}
				else {No[(Math.max(x1,x2))][y1]+=2;}			
			}
			int Total[][] = new int [gx+1][gy+1];
			Total[0][0] = 1;
			for (int i=0; i<=gx; i++){
				for (int j=0; j<=gy; j++){
					if (No[i][j] == 0){
						if (i>0 & j>0){
							Total[i][j]=Total[i-1][j]+Total[i][j-1];
						}
						else if (i>0){
							Total[i][j]=Total[i-1][j];
						}
						else if (j>0){
							Total[i][j]=Total[i][j-1];
						}
						else;
					}
					else if(No[i][j] == 1){
						if (i>0){
							Total[i][j]=Total[i-1][j];
							}
						else Total[i][j]=0;
					}
					else if(No[i][j] == 2){
						if (j>0){
						Total[i][j]=Total[i][j-1];
						}
						else Total[i][j]=0;
					}
					else {
						Total[i][j]=0;
					}
				}
			}
			if (Total[gx][gy]>0){
				System.out.println(Total[gx][gy]);
			}
			else {System.out.println("Miserable Hokusai!");
			}
		}
	}
}

Measured memory_bytes: 33484
#include<stdio.h>

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

  int m[110],i,min=1000,ans=0;
  for(i=0;i<n;i++){
    scanf("%d",&m[i]);
    if(m[i]<min)
      min = m[i];
    ans++;
    x -= m[i];
  }

  ans += x/min;

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1728
N, W = map(int, input().split())
WV = [tuple(map(int, input().split())) for _ in range(N)]

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


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


Measured memory_bytes: 120172
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

vector<vector<ll>> g(100010); 
vector<ll> dist(100010);

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

    ll x[n], y[n];
    rep(i, n)cin >> x[i] >> y[i];

    ll ans = -1;

    rep(i, n)for(int j = i+1; j < n; ++j){
        rep(k, n)for(int l = k+1; l < n; ++l){
            ll x_max = max(x[i], x[j]);
            ll x_min = min(x[i], x[j]);
            ll y_max = max(y[k], y[l]);
            ll y_min = min(y[k], y[l]);

            ll cnt = 0;
            rep(p, n){
                if(x[p] <= x_max && x[p] >= x_min && y[p] <= y_max && y[p] >= y_min){
                    cnt++;
                }
            }

            if(cnt >= K){
                if(ans < 0)ans = (x_max-x_min)*(y_max-y_min);
                else ans = min(ans, (x_max-x_min)*(y_max-y_min));
            }
        }
    }

    cout << ans << endl;
}

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

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<P> p(n);
    rep (i, n) cin >> p[i].first >> p[i].second;
    sort(all(p));
    int now = 0, ans = 0;
    priority_queue<int> pq;
    rep (i, m + 1) {
        while (now < n && p[now].first <= i) {
            pq.push(p[now].second);
            now++;
        }
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1660
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	vector<vector<int>> a(n, vector<int>(0));
	for(int i = 0, j, k; i < m; ++i)
	{
		scanf("%d%d", &j, &k);
		a[--j].push_back(--k);
		a[k].push_back(j);
	}
	for(int i = 0; i < a[0].size(); ++i)
	{
		for(int j = 0; j < a[a[0][i]].size(); ++j)
		{
			if(a[a[0][i]][j] == n - 1)
			{
				printf("POSSIBLE\n");
				return 0;
			}
		}
	}
	printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 12016
#include<iostream>
int n[100000], m[100000];
int N, M;
long long ans;
long long s = 1000000000 + 7;
long long kai(int a) {
	long long fu = 1;
	for (int i = 1; i <= a; i++) {
		fu = fu * i;
		if (fu > s) {
			fu = fu%s;
		}
	}
	return fu;
}
int main() {
	std::cin >> N >> M;
	long long Nkai = kai(N);
	long long Mkai = kai(M);
	if (N == M) {
		if (Nkai >= s) {
			Nkai = Nkai%s;
			ans = 2 * Nkai*Mkai;
		}
		else {
			ans = (2 * Nkai*Mkai) % s;
		}
	}
	else if (N - M == 1 || N - M == -1) {
		ans = (Nkai*Mkai) % s;
	}
	else {
		ans = 0;
	}
	std::cout << ans << "\n";
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;

public class Main{

	public static int f(char c){
		return c=='I'?1:
			c=='V'?5:
			c=='X'?10:
			c=='L'?50:
			c=='C'?100:
			c=='D'?500:1000;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] s = sc.next().toCharArray();
			int sum = 0;
			int i;
			for(i=0;i<s.length-1;i++){
				if(f(s[i])>=f(s[i+1]))sum+=f(s[i]);
				else{
					sum += f(s[i+1])-f(s[i]);
					i++;
				}
			}
			if(i<s.length)sum += f(s[i]);
			System.out.println(sum);
		}
	}
	
}

Measured memory_bytes: 17268
#include <stdio.h>
#include <math.h>
typedef struct p{
	double x;
	double y;
}p;

void kock(int,p,p);

int main(){
	int n;
	p p1,p2;
	p1.x = 0.0;
	p1.y = 0.0;
	p2.x = 100.0;
	p2.y = 0.0;

	scanf("%d",&n);
	printf("%.8f %.8f\n",p1.x,p1.y);
	kock(n,p1,p2);
	printf("%.8f %.8f\n",p2.x,p2.y);
	return 0;
}


void kock(int n,p p1,p p2){
	p s,l,u;
	if(n == 0) return ;

	s.x = (2*p1.x + 1*p2.x)/3.0;
	s.y = (2*p1.y + 1*p2.y)/3.0;
	l.x = (1*p1.x + 2*p2.x)/3.0;
	l.y = (1*p1.y + 2*p2.y)/3.0;
	u.x = (l.x-s.x)*cos(M_PI/3)-(l.y-s.y)*sin(M_PI/3)+s.x;
	u.y = (l.x-s.x)*sin(M_PI/3)+(l.y-s.y)*cos(M_PI/3)+s.y;


		kock(n-1,p1,s);
		printf("%.8f %.8f\n",s.x,s.y);
		kock(n-1,s,u);
		printf("%.8f %.8f\n",u.x,u.y);
		kock(n-1,u,l);
		printf("%.8f %.8f\n",l.x,l.y);
		kock(n-1,l,p2);

}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll k, a, b;
    cin >> k >> a >> b;
    
    if (b-a <= 2) {
        cout << 1 + k << endl;
        return 0;
    }
    ll now = 1;
    while (now < a && k > 0) {
        now++;
        k--;
    }
    if (k&1) {
        now++;
        k--;
    }
    now += (k/2) * (b-a);
    cout << now << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


signed main() {

    int n;
    cin >> n;
    vector<int> a(n);

    ll sum = 0;
    ll ans = 1;

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

    cout << ans - 1<< endl;

    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll d,t,s;
  
  cin>>d>>t>>s;
  
  if(s*t>=d)
  cout<<"Yes\n";
  else
  cout<<"No\n";
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {

	int N;
	cin >> N;

	double T, A;
	cin >> T >> A;

	int m;
	double *apm = new double[N];
	for (int i = 0; i < N; i++) {
		cin >> m;
		apm[i] = T - m * 0.006;
	}

	bool first = true;
	double mf = 61.0;
	int ki = -1;
	for (int i = 0; i < N; i++) {
		double x = fabs(A - apm[i]);
		if (first) {
			mf = x;
			ki = i;
			first = false;
		} else {
			if (x < mf) {
				mf = x;
				ki = i;
			}
		}
	}

	delete[] apm;

	cout << (ki + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A;
        A = new int[n];
        int count = 0;
        for(int i=0;i<n;++i){
            A[i] = sc.nextInt();
        }


        int minj;
        for(int i=0;i<n-1;++i){  //selectionsort
            minj = i;
            for(int j=i;j<n;++j){
                if(A[j] < A[minj]){
                    minj = j;
                }
            }
            if(i!=minj){
                int c;
                c = A[i];
                A[i] = A[minj];
                A[minj] = c;
                count++;
            }
        }

        print(A, n);
        System.out.println(count);
    }

    public static void print(int A[], int n){
        for(int i=0;i<n;++i){
            System.out.print(A[i]);
            if(i<n-1){System.out.print(" ");}
        }
        System.out.println();
    }
}



Measured memory_bytes: 26428
#
# s8pc4 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例1(self):
        input = """5 5
3949 3774 3598 3469 3424"""
        output = """1541"""
        self.assertIO(input, output)

    def test_入力例2(self):
        input = """5 3
7 4 2 6 4"""
        output = """7"""
        self.assertIO(input, output)

    def test_入力例3(self):
        input = """2 2
7 8"""
        output = """0"""
        self.assertIO(input, output)


def resolve():
    N, K = map(int, input().split())
    a0, *A = map(int, input().split())

    ans = float("inf")
    for bit in range(1 << (N-1)):
        if bin(bit).count("1") != K-1:
            continue
        cost = 0
        target = a0+1
        for i, a in enumerate(A):
            if (1 << i) & bit == (1 << i):
                cost += max(0, target-a)
                target = a + max(0, target-a) + 1
            else:
                if a > target:
                    target = a+1
        ans = min(ans, cost)

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i=0; i<n; ++i) cin >> a[i];
    for (int i=0; i<m; ++i) cin >> b[i];
    bool ans = false;
    for (int i=0; i<n-m+1; ++i) {
        for (int j=0; j<n-m+1; ++j) {
            vector<string> copa(m);
            for (int k=0; k<m; ++k) {
                copa[k] = a[i+k].substr(j, m);
            }
            if (copa == b) ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
while True:
  H, W=map(int, input().split())
  if H==0 and W==0:
    break
  for i in range(H):
    if i==0 or i==H-1:
      for j in range(W):
        print("#", end="")
    else:
      for j in range (W):
        if j==0 or j==W-1:
          print("#", end="")
        else:
          print(".", end="")
    print()
  print()


Measured memory_bytes: 7000
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    for(int j=i;j<n-1;j++){
      int k=j;
      while(a[k+2]<a[i]+a[j+1]&&k<n-2){
        ans++;
        k++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
    AUTHOR : TANMAY SINHA
    INORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(i,L,R) for(i=L;i<R;i++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5+10,MAX = 500500;
#define sq(X) ((X)*(X))

int main()
{
    ll n,k,i;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ll s=0;
    for(i=0;i<n-k;i++)
    {
        s+=a[i];
    }
    cout<<s<<"\n";
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {

	int n = 0;
	double x[10] = {},ans = 0;
	string u[10] = {};
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> u[i];
	}

	rep(i, n) {

		if (u[i] == "JPY") {
			ans += x[i];
		}
		else {
			ans += 380000.0 * x[i];
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int):
    print(YES if (A == B or B == C or A == C) and not A == B == C else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int X,Y,Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
 }


Measured memory_bytes: 256
N = int(input())
S = input()

tried_first_digit = {}
tried_second_digit = {}
password = {}

for i in range(N-2):
    if S[i] not in tried_first_digit:
        tried_first_digit[S[i]] = 0
        for j in range(i+1, N-1):
            if S[i]+S[j] not in tried_second_digit:
                tried_second_digit[S[i]+S[j]] = 0
                for k in range(j+1, N):
                    if S[i]+S[j]+S[k] not in password:
                        password[S[i]+S[j]+S[k]] = 0

print(len(password))


Measured memory_bytes: 73432
#include<bits/stdc++.h>
using namespace std;
string s1, s2;
int main()
{
	int num = 0;
	cin >> s1 >> s2;
	int len1 = s1.length();
	int len2 = s2.length();
	for(int i = 0; i < len1; i++){
			if(s1[i] == s2[i]){
				num++;
			}
	}
	cout << num << endl;
}

Measured memory_bytes: 256
S = input()
ans = 0
if S == 'SUN':
  ans = 7
elif S == 'SAT':
  ans = 1
elif S == 'FRI':
  ans = 2
elif S == 'THU':
  ans = 3
elif S == 'WED':
  ans = 4
elif S == 'TUE':
  ans = 5
else:
  ans = 6
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p;
  string s;
  cin>>n>>p>>s;
  if(p==2||p==5){
    int64_t a=0;
    for(int i=0;i<n;i++)
      a+=((int)(s.at(i)-'0')%p==0?i+1:0);
    cout<<a<<endl;
    return 0;
  }
  vector<int> b(p,0);
  b.at(0)=1;
  for(int i=n-1,x=0,d=1;i>=0;i--,d=d*10%p){
    x=(x+(int)(s.at(i)-'0')*d)%p;
    b.at(x)++;
  }
  int64_t a=0;
  for(int i=0;i<p;i++)
    a+=(int64_t)b.at(i)*(b.at(i)-1)/2;
  cout<<a<<endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main (){
  int N,K;
  cin>>N>>K;
  int ans=1;
  rep(i,N){
    ans=min(ans*2,ans+K);
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int X;
    cin >> X;
    int ans = 1;
    for (int p = 2; p <= 10; ++p) {
        for (int b = 2; pow(b, p) <= X; ++b) {
            ans = max(ans, (int)pow(b, p));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
# 2019/03/17
# AtCoder Grand Contest 031 - A

# Input
n = int(input())
s = input()

aprcnt = [1] * 26

# Count up Alphabets
for idx in range(n):
    w_idx = ord(s[idx]) - 97
    aprcnt[w_idx] += 1

# Calc Combination count
ans = 1
for idx in range(26):
    ans = ans * aprcnt[idx]

# Reduces 1 in choose nothing case
ans -= 1
ans = ans % (10**9 + 7)

# Output
print(ans)


Measured memory_bytes: 3188
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int q = sc.nextInt();
			TreeMap<Integer, Integer> s = new TreeMap<>();
			int length = 0;
			for(int i = 0; i < q; i++) {
				int query = sc.nextInt();
				int key;
				switch(query) {
				case 0:
					key = sc.nextInt();
					s.put(key, s.getOrDefault(key, 0) + 1);
					length++;
					System.out.println(length);
					break;
				case 1:
					System.out.println(s.getOrDefault(sc.nextInt(), 0));
					break;
				case 2:
					key = sc.nextInt();
					length -= s.getOrDefault(key, 0);
					s.remove(key);
					break;
				case 3:
					Map<Integer, Integer> sub = s.subMap(sc.nextInt(), true, sc.nextInt(), true);
					for (Map.Entry<Integer, Integer> n : sub.entrySet()) {
						for(int j = 0; j < n.getValue(); j++) {
							System.out.println(n.getKey());
						}
					}
				}
			}
		}
	}
}


Measured memory_bytes: 173184
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class DRainFlowsIntoDams {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int n;
        cin >> n;
        vector<int64_t> a_vec(n);
        for (int i = 0; i < n; ++i) {
            cin >> a_vec[i];
        }
        vector<int64_t> simulation_vec(n);
        vector<int64_t> mountain(n);
        mountain[0] = 0;
        for (int i = 1; i < n; ++i) {
            mountain[i] = (a_vec[i - 1] - mountain[i - 1] / 2) * 2;
        }
        mountain[0] = (a_vec[n - 1] - mountain[n - 1] / 2);
        for (int i = 1; i < n; ++i) {
            mountain[i] = (a_vec[i - 1] - mountain[i - 1] / 2) * 2;
        }

        for (const auto &item : mountain) {
            cout << item << " ";
        }
        cout << endl;
    }
};


int main() {
    DRainFlowsIntoDams solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
long long mon[100005];
int main(){
    int a;
    long long b;
    cin >> a >> b;
    for (int i = 0; i < a; ++i) {
        int aa, bb;
        cin >> aa >> bb;
        mon[aa] += bb; 
    }
    for (int i = 1; i <= 100005; ++i){
        if (b <= mon[i]) {
            cout << i << endl;
            break; 
        }
        b -= mon[i];
    }
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC" << endl;
	else if (s == "ARC") cout << "ABC" << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

int main(){
    int A,B,T; cin >> A >> B >> T;
    int test;
    test = ( T/A )*B ;
    cout << test;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string s;
  cin>>s;
  int l=s.length()-2;
  int i=0;
  cout<<s[i];
  cout<<l;
  cout<<s[l+1];
  
  
  
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int N=2e6+5,P=1e9+7;
int n,X1,X2,X3,X4,X5,X6,Y1,Y2,Y3,Y4,Y5,Y6;ll fc[N],xf[N],As;
ll fpm(ll x,ll y){ll s=1;while(y){ if(y&1) s=(s*x)%P; y>>=1,x=(x*x)%P;}return s;}
inline ll C(int n,int m){return fc[n]*xf[m]%P*xf[n-m];}
inline ll F(int X1,int Y1,int X2,int Y2){return ((C(X2+Y2+2,X2+1)-C(X2+Y1+1,Y1)-C(X1+Y2+1,X1)+C(X1+Y1,X1))%P+P)%P;}
int main()
{
	std::cin>>X1>>X2>>X3>>X4>>X5>>X6>>Y1>>Y2>>Y3>>Y4>>Y5>>Y6;
	for(int i=fc[0]=xf[0]=1;i<N;++i)fc[i]=(fc[i-1]*i)%P;
	xf[N-1]=fpm(fc[N-1],P-2);
	for(int i=N-2;i>=0;i--)xf[i]=(xf[i+1]*(i+1))%P;
	for(int i=X3;i<=X4;++i)(As+=F(i-X2,Y3-1-Y2,i-X1,Y3-1-Y1)*F(X5-i,Y5-Y3,X6-i,Y6-Y3)%P*(P-i-Y3))%=P;
	for(int i=Y3;i<=Y4;++i)(As+=F(X3-1-X2,i-Y2,X3-1-X1,i-Y1)*F(X5-X3,Y5-i,X6-X3,Y6-i)%P*(P-X3-i))%=P;
	for(int i=X3;i<=X4;++i)(As+=F(i-X2,Y4-Y2,i-X1,Y4-Y1)*F(X5-i,Y5-1-Y4,X6-i,Y6-1-Y4)%P*(i+Y4+1))%=P;
	for(int i=Y3;i<=Y4;++i)(As+=F(X4-X2,i-Y2,X4-X1,i-Y1)*F(X5-1-X4,Y5-i,X6-1-X4,Y6-i)%P*(X4+i+1))%=P;
	return std::cout<<As<<std::endl,0;
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,x;
    cin >> a >> b >> x;
    c=b/x;
    c-=a/x;
    if(a%x==0)c++;
    cout << c << endl;
    return 0;
}




Measured memory_bytes: 384
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
local str2tbl = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
a,b=read.nnl()
s=str2tbl(read.l())
ok=true
for i=1,a do ok=ok and ("0123456789"):find(s[i]) end
ok=ok and s[a+1]=='-'
offset=a+1
for i=offset+1,offset+b do ok=ok and ("0123456789"):find(s[i]) end
print(ok and 'Yes' or 'No')

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

int main() {
		int a[10];
		int b[10];
		for (int i = 0; i < 10; i++){
			cin >> a[i];
		}
		sort(a, a + 10);
		cout << a[9] + a[8] + a[7] << " ";
		for (int i = 0; i < 10; i++){
			cin >> b[i];
		}
		sort(b, b + 10);
		cout << b[9] + b[8] + b[7] << endl;
	}

Measured memory_bytes: 1180
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();

    sc.close();

    int count = 0;

    for (int i = 105; i <= N; i++) {
      
      int count_ = 0;

      if (i % 2 == 1) { 
      
        for (int j = 1; j <= i; j++) {
          if (i % j == 0) {
            count_++;
          }
        }

      }

      if (count_ == 8) {
        count++;
      }

    }

    System.out.println(count);

  }

}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

const int INF = 1e9 + 10;

struct Edge {
  int to, dist, constraint;
 
  Edge() = default;
  Edge(int t, int d, int c): to(t), dist(d), constraint(c) { }
};

struct Node {
  double cost;
  int cur, prev, v;
  
  Node() = default;
  Node(double c, int cur, int prev, int v): cost(c), cur(cur), prev(prev), v(v) { }

  inline bool operator<(const Node& node) const {
    return cost < node.cost;
  }

  inline bool operator>(const Node& node) const {
    return cost > node.cost;
  }
};


int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n + m == 0) {
      break;
    }
    int s, g;
    cin >> s >> g;

    vector<Edge> G[31];
    for (int i = 0; i < m; i++) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      G[x].push_back(Edge(y, d, c));
      G[y].push_back(Edge(x, d, c));
    }

    double min_cost[31][31][31];
    for (int i = 0; i < 31; i++)  {
      for (int j = 0; j < 31; j++) {
        for (int k = 0; k < 31; k++) {
          min_cost[i][j][k] = INF;
        }
      }
    }

    priority_queue<Node, vector<Node>, greater<Node>> que;
    min_cost[s][0][1] = 0;
    que.push(Node(0, s, -1, 0));

    while (!que.empty()) {
      Node node = que.top(); que.pop();

      for (const auto& e : G[node.cur]) {
        if (node.prev == e.to) {
          continue;
        }
        const int dv[3] = { -1, 0, 1 };
        for (int i = 0; i < 3; i++) {
          int nv = node.v + dv[i];
          if (nv > 0 && nv <= e.constraint) {
            double temp = e.dist / (double)nv;
            if (min_cost[e.to][node.cur][nv] > node.cost + temp) {
              min_cost[e.to][node.cur][nv] = node.cost + temp;
              que.push(Node(node.cost + temp, e.to, node.cur, nv));
            }
          }
        }
      }
    }

    double ans = INF;
    for (int i = 1; i <= n; i++) {
      ans = min(ans, min_cost[g][i][1]);
    }
    if (ans >= INF) {
      cout << "unreachable" << endl;
    } else {
      printf("%.15f\n", ans);
    }
  }

  return 0;
}

Measured memory_bytes: 3884
# E - Knapsack 2
from collections import defaultdict


def knapsack_heavy(limit: int, weight: list, value: list) -> int:
    dp = defaultdict(lambda: 1 << 30)  # dp[i] := minimum weight at value i
    dp[0] = 0
    for w, v in zip(weight, value):
        for cur_v, cur_w in tuple(dp.items()):
            if w + cur_w <= limit:
                dp[v + cur_v] = min(dp[v + cur_v], w + cur_w)
    return max(dp.keys())


def main():
    N, W, *WV = map(int, open(0).read().split())
    print(knapsack_heavy(W, WV[::2], WV[1::2]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 68956
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
int x=0;
int h=2;
  int a[6000]={0};

  a[1]=2;

  	for(int i=3;i<=10000;i+=2)
  	{
      int j,k;
  		k=0;
  		for(j=3;j<=sqrt(i);j+=2)
  		{
  			if(i%j==0)
  			{
  				k=1;
  				break;
  			}
  		}
      if(k==0){
        a[h]=i;
        h++;
      }
    }

int k=0;
  for(int i=1;i<=300;i++)
  {
    if(a[i]%5==1){
    cout<<a[i]<<" ";
    k++;
    }
    if(k==N)break;
  }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
a = gets.split(" ").map!{|i| i.to_i}
n1 = 0
n2 = 0
n3 = 0
n4 = 0
4.times do |i|
  if a[i] == 1 then n1 += 1
  elsif a[i] == 7 then n2 += 1
  elsif a[i] == 9 then n3 += 1
  elsif a[i] == 4 then n4 += 1
  end
end
if n1 == 1 and n2 == 1 and n3 == 1 and n4 == 1 
  puts "YES"
else puts "NO"
end

Measured memory_bytes: 1788
#!python3.8
# -*- coding: utf-8 -*-
# abc175/abc175_c
import sys
import math

def s2nn(s): return [int(c) for c in s.split(' ')]
def ss2nn(ss): return [int(s) for s in list(ss)]
def ss2nnn(ss): return [s2nn(s) for s in list(ss)]
def i2s(): return sys.stdin.readline().rstrip()
def i2n(): return int(i2s())
def i2nn(): return s2nn(i2s())
def ii2ss(n): return [i2s() for _ in range(n)]
def ii2nn(n): return ss2nn(ii2ss(n))
def ii2nnn(n): return ss2nnn(ii2ss(n))


def main():
    X, K, D = i2nn()
    absX = abs(X)
    if absX >= K * D:
        print(abs(absX - K * D))
        return
    a, c = divmod(absX, D)
    b = K - a
    if b % 2:
        print(abs(c - D))
    else:
        print(abs(c))
    return


main()


Measured memory_bytes: 9232
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> v(h);
    rep(i,h) cin >> v[i];
    vector<vector<int>> s(h,vector<int>(w));
    rep(i,h) rep(j,w) s[i][j] = v[i][j]-'0';
    vector<vector<int>> sum(h+1,vector<int>(w+1));
    rep2(i,1,h+1) rep2(j,1,w+1) {
        sum[i][j] = sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+s[i-1][j-1];
    }
    int ans = inf;
    rep(i,1<<(h-1)) {
        vector<int> cut;
        rep(j,h-1) if(i&(1<<j)) cut.pb(j);
        vector<vector<int>> nsum(cut.size()+2,vector<int>(w+1));
        rep2(j,1,w+1) {
            rep2(l,1,cut.size()+2) {
                int up = -1;
                if(l > 1) up = cut[l-2];
                int down = h-1;
                if(cut.size() != 0 && l != cut.size()+1) down = cut[l-1];
                nsum[l][j] = sum[down+1][j]-sum[up+1][j];
            }
        }
        int nans = cut.size();
        int last = -1;
        bool ok = true;
        rep(j,w) {
            int mx = 0;
            rep(l,cut.size()+1) chmax(mx,nsum[l+1][j+1]-nsum[l+1][last+1]);
            if(mx > k) {
                if(j-last == 1) {
                    ok = false;
                    break;
                } else {
                    nans++;
                    last = j-1;
                }
            }
        }
        if(!ok) continue;
        chmin(ans,nans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;
typedef long long ll;

int main(void) {
	int n, v;
	vector<int> e(100005),o(100005);
	cin >> n;
	int i;
	int e_max_count = 0, o_max_count = 0;
	int e_max = 0, o_max = 0;
	REP(i, n) {
		cin >> v;
		if (i % 2 == 0) {
			e[v]++;
			if (e_max_count < e[v]) {
				e_max_count = e[v];
				e_max = v;
			}
		}
		else {
			o[v]++;
			if (o_max_count < o[v]) {
				o_max_count = o[v];
				o_max = v;
			}
		}
	}
	sort(e.begin(), e.end(),std::greater<int>());
	sort(o.begin(), o.end(), std::greater<int>());
	int ans;
	if (e_max != o_max) ans = n - e_max_count - o_max_count;
	else {
		ans = n - max(e_max_count + o[1], o_max_count + e[1]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024