akhauriyash/Code-Regression huggingface dataset:
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Even Relation
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef queue<int> qi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

vpii nbrs[MAX_N];
int cs[MAX_N], ps[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 1; i < n; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    u--, v--, w &= 1;
    nbrs[u].push_back(pii(v, w));
    nbrs[v].push_back(pii(u, w));
  }

  cs[0] = 0, ps[0] = -1;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = ps[u], &uc = cs[u];
    vpii &nbru = nbrs[u];

    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = vit->first, &w = vit->second;
      if (v != up) {
	cs[v] = uc ^ w;
	ps[v] = u;
	q.push(v);
      }
    }
  }

  for (int i = 0; i < n; i++) printf("%d\n", cs[i]);
  return 0;
}


Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

const int INF = 100000000;

struct edge {
    int to, cost;
    bool operator<(const edge& r)const{
        return cost>r.cost;
    }
};

// state = edge
// struct state {
//     int from, d;
// };
vector<vector<edge> > G;
int V;

bool used[111];
int prim(){
    int sum=0;
    int es=0;
    memset(used,0,sizeof(used));
    priority_queue<edge> q;
    q.push({0,0});
    while(es!=G.size()){
        edge e=q.top(); q.pop();
        if(used[e.to])continue;
        es++;
        used[e.to]=1;
        int from=e.to;
        //cout<<" "<<from<<endl;
        sum+=e.cost;
        FOR(i,0,G[from].size()){
            if(!used[G[from][i].to])
            q.push(G[from][i]);
        }
    }
    return sum;
}

int main(){
    int m;
    while(1){
        cin>>V>>m;
        if(!(m||V))break;
        G=vector<vector<edge> >(V);
        FOR(i,0,m){
            int a,b,cost;cin>>a>>b>>cost;
            G[a].push_back({b,cost});
            G[b].push_back({a,cost});
        }
        cout<<prim()<<endl;
    }
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{

  unsigned int key;
  struct node *next;
  struct node *prev;

};

typedef struct node *Pointer;

Pointer nil;

void in()
{
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
Pointer listSearch(int key)
{
  Pointer n;

  for( n=nil->next; n != nil; n=n->next )
    {
      if( n->key == key ) return n;
    }
  return nil;
}

void printList()
{
  Pointer c = nil->next;
  
  int i = 1;

  while(1)
    {
      if( c == nil ) break;
      if( i == 0 ) printf(" ");
      printf("%d", c->key);
      c = c->next;
      i = 0;
    }
  printf("\n");
}


void deleteNode(Pointer t)
{
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}


void deleteFirst()
{
  Pointer a = nil->next;
  
  if( a == nil ) return;
  deleteNode(a);
}


void deleteLast()
{
  Pointer a = nil->prev;

  if( a == nil ) return;
  deleteNode(a);
 
}


void delete(int key)
{
  Pointer x;

  if( (x = listSearch(key)) == nil ) return;
  
  x->prev->next = x->next;
  
  x->next->prev = x->prev;


  free(x);

  
}

void insert(int key)
{
  Pointer x;
  
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main()
{
  int p = 0, d = 0;
  int key, n, i,size = 0;
  char o[20];

  
 

  scanf("%d", &n);
  in();

  for( i=0; i<n; i++ )
    {
      scanf("%s%d", o, &key);
     
      if( strcmp(o,"insert")==0)
	{
	  insert(key);
	  p++;
	  size++;
	}

       if(strcmp(o,"delete")==0)
	{
	  delete(key);
	  d++;
	   size--;
	}

  if(strcmp(o,"deleteFirst")==0){
    deleteFirst();
    size--;
  }
  if(strcmp(o,"deleteLast")==0){
    deleteLast();
    size--;
  }
}

printList();

return 0;
}

  




Measured memory_bytes: 32952
import sys

N, K, C = map(int, input().split())
S = list(input())

ini = []
las = []


cnt = C
for c, i in enumerate(S):
    if cnt >= C and i == "o":
        ini.append(c)
        cnt = 0
    else:
        cnt += 1

cnt = C
for c, i in enumerate(reversed(S)):
    if cnt >= C and i == "o":
        las.append(len(S) - c - 1)
        cnt = 0
    else:
        cnt += 1

las = sorted(las)

if len(ini) > K:
    sys.exit()

for i, j in zip(ini, las):
    if i == j:
        print(i+1)

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

main(){
  char ch;
  int K, U, P, C;
  K = U = P = C = 0;
  while( cin >> ch ){
    if ( ch == 'K' ) K++;
    if ( ch == 'U' ) U++;
    if ( ch == 'P' ) P++;
    if ( ch == 'C' ) C++;
  }
  cout << min(K, min(U, min(P, C))) << endl;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 200000
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int  n;
    IN(n);
    int cnt=0;
    bool f=true;
    REP(i,n){
        int p;
        IN(p);
        if(p!=(i+1))cnt++;
        if(cnt>2){
            f=false;
            break;
        }
    }
    if(f)OUT("YES");
    else OUT("NO");
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (N, W) = pairIntLong()
    val WV = Array(N) { pairIntLong() }
    val WVs = Array(4) { mutableListOf<Long>() }
    val baseW = WV[0].first.toLong()
    WV.forEach { wv -> WVs[wv.first - WV[0].first].add(wv.second) }
    WVs.forEach {
        it.sortDescending()
        it.add(0, 0)
    }
    var ans = 0L
    for (n0 in (0 until WVs[0].size).reversed()) {
        val w0 = (baseW + 0) * n0
        for (n1 in (0 until WVs[1].size).reversed()) {
            val w1 = (baseW + 1) * n1
            for (n2 in (0 until WVs[2].size).reversed()) {
                val w2 = (baseW + 2) * n2
                for (n3 in (0 until WVs[3].size).reversed()) {
                    val w3 = (baseW + 3) * n3
                    if (w0 + w1 + w2 + w3 > W) continue
                    val v0 = WVs[0].subList(0, n0 + 1).sum()
                    val v1 = WVs[1].subList(0, n1 + 1).sum()
                    val v2 = WVs[2].subList(0, n2 + 1).sum()
                    val v3 = WVs[3].subList(0, n3 + 1).sum()
                    ans = Math.max(ans, v0 + v1 + v2 + v3)
                }
            }
        }
    }
    println(ans)
}
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 42292
import numpy as np
S = str(input())
array = np.array([int(i) for i in S])

num_1 = sum(array)
num_0 = len(array) - num_1

nokori = max(num_1, num_0) - min(num_1, num_0)
answer = len(array) - nokori
print(answer)

Measured memory_bytes: 17356
#include <stdio.h>

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

	if (a < b) {
		printf("a < b\n");
	} else if (a > b) {
		printf("a > b\n");
	} else {
		printf("a == b\n");
	}

	return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a,*b;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
const int maxn=1e5+1;
int n,a[maxn],d;
bool get(int x,int y) {
	if (x>n || y>a[x]) return true;
	int p;
	for (int i=1;i<=n;++i) if (a[i]>=y) p=i; else break;
	return (p+a[p]-x-y)&1;
}
int main() {
	generate(a+1,a+(n=read())+1,read);
	sort(a+1,a+n+1,greater<int>());
	for (int i=1;i<=n;++i) if (a[i]>=i) d=i; else break;
	puts(!get(d,d+1) || !get(d+1,d)?"First":"Second");
	return 0;
}


Measured memory_bytes: 1664
s = input()
space = len(s) - 1
ans = 0

for i in range(2 ** space):
    formula = s[0]
    for j in range(space):
        if (i >> j) & 1:
            formula += "+"
        else:
            formula += "-"
        formula += s[j + 1]
    if eval(formula) == 7:
        print("{}=7".format(formula))
        break


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

using namespace std;

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

  int D, G;
  cin >> D >> G;
  G /= 100;
  vector<vector<int>> points(D);
  int p, c;
  for (int i = 0; i < D; ++i) {
    cin >> p >> c;
    points[i] = {p, (i+1), c/100};
  }
  int res = 1e9, g, cnt, scr, tmp;
  vector<int> ord(D);
  iota(ord.begin(), ord.end(), 0);
  do {
    g = G;
    cnt = 0;
    for (int i = 0; i < D; ++i) {
      p = points[ord[i]][0];
      scr = points[ord[i]][1];
      c = points[ord[i]][2];
      tmp = (g+scr-1)/scr;
      cnt += (tmp < p ? tmp : p);
      g -= p * scr + c;
      if (g <= 0) break;
    }
    if (cnt < res) res = cnt;
  } while (next_permutation(ord.begin(), ord.end()));
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
num = [0 for i in range(3)]
suma = 1
mod = 10**9+7
for i in A:
    suma = (suma*num.count(i))%mod
    if num[0] == i:
        num[0] += 1
    elif num[1] == i:
        num[1] += 1
    else:
        num[2] += 1
print(suma)

Measured memory_bytes: 14092
n=input()
for _ in [0]*n:
  s=raw_input()
  A=s[0]
  for i in range(0,len(s),3):
    if s[i:i+3]==(A[-1]+"->"): A+=s[i+3]
    elif s[i:i+3]==(A[0]+"<-"): A=s[i+3]+A
  print "".join(A)

Measured memory_bytes: 4212
import math

d, g = [int(i) for i in input().split(" ")]
p = [0] * (d + 1)
c = [0] * (d + 1)

for i in range(1, d + 1):
    p[i], c[i] = [int(i) for i in input().split(" ")]

p_min = 10000

def cp(a):
    global p_min
    r = g - sum([(p[i] * 100 * i + c[i]) * a[i] for i in range(1, d + 1)])
    ps = sum([p[i] * a[i] for i in range(1, d + 1)])
    if r <= 0:
        if ps < p_min:
            p_min = ps
        return
    
    for i in reversed(range(1, d + 1)):
        if a[i] == 0:
            s = (p[i] - 1) * 100 * i
            if r - s <= 0:
                ps += math.ceil(r / (100 * i))
                if ps < p_min:
                    p_min = ps
                break
            else:
                ps += p[i] - 1
                r -= s

def trav(a):
    global d
    if len(a) == d + 1:
        cp(a)
    else:
        trav(a + [0])
        trav(a + [1])

trav([0])

print(p_min)

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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  string a="abcdefghijklmnopqrstuvwxyz";
  a += a;

  string s;

  while(getline(cin,s)){
    //cout << s << endl;

    string t="";
    bool end=false;
    int i;
    for(int w=0; w<=25; ++w){
      //printf("w=%d\n", w);
      t="";
      int p=0;
      rep(i,s.size()){
        if('a'<=s[i] && s[i]<='z'){
          t+=a[s[i]-'a'+w];
        }
        else{
          t+=s[i];
          string tmp=t.substr(p,i-p);
          //cout << tmp << endl;

          if(tmp=="this" || tmp=="the" || tmp =="that") end=true;

          p=i+1;
        }
      }

      if(end) break;
    }

    std::cout << t << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1192
n=int(input())

mod=10**9+7

def power_func(a,n,mod):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res)%mod
    if bi[i]=='1':
      res=(res*a)%mod
  return res

x=power_func(10,n,mod)
y=power_func(9,n,mod)
z=power_func(8,n,mod)

ans=(x-(y-z)*2-z)%mod

print(ans)

Measured memory_bytes: 9204
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#A
def A():
    s = S()
    if "9" in s:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    ans = 0
    for _ in range(n):
        l, r = LI()
        ans += r - l + 1
    print(ans)
    return

#C
def C():
    n = II()
    A = {}
    for _ in range(n):
        k = II()
        if not k in A:
            A[k] = 1
        else:
            A[k] += 1
    ans = 0
    for item in A.values():
        ans += item % 2
    print(ans)
    return

#D
def D():
    n, m, R = LI()
    r = LI()
    edg = [[0 if i == k else inf for k in range(n)] for i in range(n)]
    for _ in range(m):
        a, b, c = LI_()
        edg[a][b] = c + 1
        edg[b][a] = c + 1
    for k in range(n):
        for a in range(n):
            for b in range(n):
                edg[a][b] = min(edg[a][b], edg[a][k] + edg[k][b])
    ans = inf
    fullserch = itertools.permutations(range(R), R)
    for fulls in fullserch:
        b = 0
        for i in range(R - 1):
            b += edg[r[fulls[i]] - 1][r[fulls[i + 1]] - 1]
        ans = min(ans, b)
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()

Measured memory_bytes: 57052
#include<bits/stdc++.h>                          
using namespace std;
int n,p,w,g,y;
string s;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>s;
    	if(s[0]=='P') p++;
    	if(s[0]=='W') w++;
    	if(s[0]=='G') g++;
    	if(s[0]=='Y') y++;
	}
	if(p>=1&&w>=1&&g>=1&&y>=1) cout<<"Four";
	else cout<<"Three";
	return 0;
}
//68871358
//76140264
//25446011
//200841159

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  char s[10001];
  int N;
  scanf("%d",&N);
  scanf("%s",&s);
  for(int i=0;i<strlen(s);i++){
	s[i]+=N;
    if(s[i]>90){
      s[i]-=26;
    }
  }
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

#define MAX 100
#define NIL (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int m[MAX][MAX],n;
int color[MAX];
int d[MAX];

void visit(){
    int minv;
    for(int i = 0; i < n; i++){
        color[i] = WHITE;
        d[i] = NIL;
    }
    color[0]=GRAY;
    d[0] = 0;
    while(1){
        minv = NIL;
        int u = -1;
        for(int i = 0; i < n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1){
            break;
        }
        color[u]=BLACK;
        for(int v = 0; v < n; v++){
            if(color[v] != BLACK && m[u][v] != NIL){
                if(d[v]>d[u]+m[u][v]){
                    d[v] = d[u] + m[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for (int i = 0; i < n; i++){
        cout << i << " " << (d[i] == NIL?-1:d[i]) << endl;
    }
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            m[i][j] = NIL;
        }
    }
    int k, c, u, v;
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        for(int j = 0;j < k; j++){
            cin >> v >> c;
            m[u][v] = c;
        }
    }
    visit();
    return 0;
}



Measured memory_bytes: 3128
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let mut a: usize = scan(tokens);
    let mut b: usize = scan(tokens);
    while b != 0 {
        let c = a % b;
        a = b;
        b = c;
    }
    let mut ans = 1;
    for d in 2.. {
        if a == 1 {
            break;
        }
        if a < d * d {
            ans += 1;
            break;
        }
        if a % d == 0 {
            ans += 1;
            while {
                a /= d;
                a % d == 0
            } {}
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n, k;
int a[N];

int dp[N];
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 2; i <= n; ++i)
    {
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        for (int j = i - 2; j >= max(1, i - k); --j)
        {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pii             pair<LL , LL >
#define inf             1000000011
#define in(a)           scanf("%lld", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%lld%lld", &a, &b)
#define in3(a, b, c)    scanf("%lld%lld%lld", &a, &b, &c)
#define pn              printf("\n")
#define pr(a)           printf("%lld\n", a)
#define prs(a)          printf("%lld ", a)
#define pr2(a, b)       printf("%lld %lld\n", a, b)
#define pr3(a, b, c)    printf("%lld %lld %lld\n", a, b, c)
#define pcs(a)          printf("Case %lld: ", a)
#define mp              make_pair
#define vi              vector<LL >
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define sz              size()
#define pb              push_back
#define mem(a, b)       memset((a), (b), sizeof(a))
#define all(X)          (X).begin(), (X).end ()
#define lg2(n)          (31-__builtin_clz(n))
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
#define x               first
#define y               second
#define lc              (2*i)
#define rc              (2*i+1)

typedef long long LL;
//LL  dx[]={1,0,-1,0};LL dy[]={0,1,0,-1}; //4 Direction
//LL  dx[]={1,1,0,-1,-1,-1,0,1,0};LL dy[]={0,1,1,1,0,-1,-1,-1,0};//8 direction
//LL  dx[]={2,1,-1,-2,-2,-1,1,2};LL dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(LL n, LL pos) {return (n & (1<<pos))>>pos;} //typecast 1 in case of int
//LL  on(LL n, LL pos) {return n | (1<<pos);} //typecast 1 in case of int
//LL  off(LL n, LL pos) {return n & ~(1<<pos);} //typecast 1 in case of int
//bool operator < (const data &d) const{return cost<d.cost;} //reverse in priority queue

const LL M = 500010, mod = 1000000007;

vi A[M];
vi W[M];
LL dist[M];
bool visited[M];

void dfs(LL u, LL dd)
{
    visited[u] = 1;
    dist[u] = dd;
    for (LL i = 0; i < A[u].size(); i++)
    {
        LL v = A[u][i];
        if (!visited[v]) dfs(v, dd+W[u][i]);
    }
}

int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("/home/lochness/Documents/in.txt", "r", stdin);
////    freopen("/home/lochness/Documents/in.txt", "w", stdout);
//#endif
//    ios_base::sync_with_stdio(false);

    LL i, j, k, n;

    in(n);
    for (LL l = 1; l < n; l++)
    {
        in3(i, j, k);
        A[i].pb(j);
        A[j].pb(i);
        W[i].pb(k);
        W[j].pb(k);
    }

    LL q, r, u, v;
    in2(q, r);
    dfs(r, 0);
    while (q--)
    {
        in2(u, v);
        pr(dist[u]+dist[v]);
    }


    return 0;
}


Measured memory_bytes: 37376
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <map>
#include <regex>
#include <sstream>
#include <utility>
#include <list>
#define endl	'\n'
#define MAX 1000000000
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
int dx[] = { 1,-1,0,0,0,0 };
int dy[] = { 0,0,-1,1,0,0 };
int dz[] = { 0,0,0,0,1,-1 };

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	double t, x;
  	cin >>  t>> x;
  	cout << t / x;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
a=list(map(int,input().split()))
l=[]
c=sum(a)/2

mi=10**12
tmp=0

for i in range(n):
    tmp+=a[i]
    l.append(tmp)
    if mi > abs((c-l[i])):
        mi=abs(c-l[i])
        k=i

print(abs(l[-1]-2*l[k]))



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

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

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

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

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

    ll a;
    cin >> a;
    cout << 3 * a * a << endl;
    return 0;
}

Measured memory_bytes: 256
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int main(){
	int H,W,h,w;
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H%h==0&&W%w==0){
		puts("No");
		return 0;
	}
	puts("Yes");
	rep(i,1,H+1){
		rep(j,1,W+1)printf("%d ",i%h==0&&j%w==0?-1-4000*(h*w-1):4000);
		puts("");
	}
}

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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll> > store(N);

    for (int i = 0; i < N; i++) {
        ll A, B; cin >> A >> B;
        store[i] = make_pair(A, B); // (price, bottle)
    }

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

    ll total_price = 0;
    for (int i = 0; M > 0; i++) {
        total_price += min(M, store[i].second) * store[i].first;
        M -= min(M, store[i].second);
    }
    cout << total_price << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector <int> A(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>A[i];
	}
	sort(A.begin(), A.end());
	bool flag = true;
	int pcmax = A.back() + 2;
	while(A.size() > 2 && flag)
	{
		int cmax = A.back();
		flag = (flag && (cmax == pcmax - 2));
		pcmax = cmax;
		int lala = 0;
		while(!A.empty() && A.back() == cmax)
		{
			A.pop_back();
			lala++;
		}
		flag = (flag && (lala >= 2));
		for (int i = 0; i < A.size(); ++i)
		{
			A[i]--;
		}
	}
	flag = (flag && (A.back() == pcmax - 2));
	bool ans = false;
	if(A.size() == 1)
		ans = (A[0] == 0);
	if(A.size() == 2)
		ans = (A[0] == A[1] && A[1] == 1);
	ans = (ans && flag);
	cout<<(ans?"Possible":"Impossible")<<"\n";
	return 0;
}

Measured memory_bytes: 384
/*
	Powered by C++11.
	Author : Alex_Wei.
*/

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

//#pragma GCC optimize(3)
//#define int long long

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

// Templates start.

namespace IO{
	char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#ifdef __WIN64
		#define gc getchar()
	#else
		#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
	#endif
	#define pc(x) (*O++=x)
	#define flush() fwrite(obuf,O-obuf,1,stdout)

	inline int read(){
		int x=0,sign=0; char s=getchar();
		while(!isdigit(s))sign|=s=='-',s=getchar();
		while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=getchar();
		return sign?-x:x;
	}
	void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}
}

namespace math{
	const int mod=1e9+7;
	const int maxn=1e6+5;

	ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%mod; m=m*m%mod,b>>=1;} return s;}
	ll inv(ll x){return ksm(x,mod-2);}

	ll fc[maxn],ifc[maxn];
	void init_m(int n){
		fc[0]=1; for(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%mod;
		ifc[n]=inv(fc[n]); for(int i=n-1;i>=0;i--)ifc[i]=ifc[i+1]*(i+1)%mod;
	}
	ll C(ll n,ll m){return fc[n]*ifc[m]%mod*ifc[n-m]%mod;}
}

// Templates end. Please give me more points.

using namespace IO;
using namespace math;

const int N=3e3+5;

int h,w,n,f[N],ans;
struct point{
	int x,y;
	bool operator < (const point &v) const {
		return x==v.x?y<v.y:x<v.x;
	}
}c[N];

int main(){
	cin>>h>>w>>n; init_m(h+w); f[0]=0;
	for(int i=1;i<=n;i++)cin>>c[i].x>>c[i].y; sort(c+1,c+n+1),c[++n]={h,w};
	for(int i=0;i<=n;i++){
		f[i]=C(c[i].x+c[i].y-2,c[i].x-1);
		for(int j=0;j<i;j++){
			int a=c[i].x-c[j].x,b=c[i].y-c[j].y;
			if(a>=0&&b>=0)f[i]=(f[i]-1ll*C(a+b,a)*f[j]%mod+mod)%mod;
		}
		if(i<n&&i)ans=(ans+1ll*f[i]*C(h+w-c[i].x-c[i].y,h-c[i].x))%mod;
	}
	cout<<(C(h+w-2,h-1)%mod-ans+mod)%mod<<endl;
	return 0;
}

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

int n;
int y;

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

  int res10000 = -1, res5000 = -1, res1000 = -1;

  for (int i=0; i <= n; ++i) {
    for (int j=0; i + j <= n; ++j) {
      int k = n - i - j;
      int sum = i * 10000 + j * 5000 + k * 1000;
      if (sum == y) {
        res10000 = i;
        res5000 = j;
        res1000 = k;
      }
    }
  }

  cout << res10000 << " " <<  res5000 << " " << res1000 << endl;
  return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
	s = readline() |> chomp
	for i in 1:7
		if a[i]==s
			println(8-i)
		end
	end
end
main()

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

int a, b, c;

int main()
{
    cin >> a >> b >> c;
    if (a == b && b == c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int A , B , a , b , p , q , r , s , x , y;
  cin >> A >> B;
  a = A / 100;
  b = B / 100;
  p = A / 10000;
  q = A % 10000 / 1000;
  r = B / 10000;
  s = B % 10000 / 1000;
  x = A % 100;
  y = B % 100;
  
  int sum = b - a + 1;
  if (q * 10 + p < x){
    sum--;
  }
  if (s * 10 + r > y){
    sum--;
  }
  cout << sum << endl;
}
  

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

using namespace std;


int main()
{
    //freopen("dulieu","r",stdin);

    int a,i,b[10]={0,0,0,0,0,0,0,0,0,0};
    for (i=0; i<4; i++)
    {
        cin >> a;
        b[a]=1;
    }
    cout << (b[1]==1 && b[9]==1 && b[7]==1 && b[4]==1 ? "YES" : "NO");



    return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
ans = 0
li=list(map(int,input().split()))
tmp = li[0]
cnt=0
for i in range(n-1):
    if (tmp >= li[i+1]):
        cnt += 1
    else:
        cnt=0
    tmp = li[i+1]
    if (ans < cnt):
        ans = cnt
print(ans)

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

int main() {
  string S;
cin >> S;

if(S.at(0)==S.at(1) && S.at(2)==S.at(3) || S.at(0)==S.at(2) && S.at(1)==S.at(3) || S.at(0)==S.at(3) && S.at(1)==S.at(2))
   {
     if (S.at(0)==S.at(1) && S.at(1)==S.at(2))
     {
       cout << "No" << endl;
     }
    else
      cout << "Yes" << endl;
   }
else
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)


{


  int a,b,d,r;


  double f;


  scanf("%d %d",&a,&b);


  d=a/b;


  r=a%b;


  f=(double)a/(double)b;


  printf("%d %d %lf",d,r,f);


  return 0;


}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  int a, b, c;
  cin >> a >> b >> c;
  pr(min((a * b), c));
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
vector<int> v;
signed main(){
	int a,b,c;
	cin>>a>>c;
	f(i,a){
		cin>>b;
		v.push_back(b);
	}
	sort(all(v));
	f(i,c){
		int d,e;
		cin>>d>>e;
		cout<<(int)(upper_bound(all(v),e)-lower_bound(all(v),d))<<endl;
	}
}




Measured memory_bytes: 3852
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toInt() - 1}
    val b = readLine()!!.split(" ").map{it.toInt()}
    val c = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    ans += b[a[0]]
    for(i in 1 until a.size){
        ans += b[a[i]]
        if(a[i] - 1 == a[i - 1]){
            ans += c[a[i - 1]]
        }
    }
    println(ans)
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
 
signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin >> a[i];
    multiset<ll> mset;

    rep(i,n){
        auto itr = mset.lower_bound(a[i]);
        if(itr != mset.begin())mset.erase(--itr);
        mset.insert(a[i]);
    }
    out(mset.size());
}


Measured memory_bytes: 8636
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func PrimeFactorsMap(n int) map[int]int {
	pfs := map[int]int{}
	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2]++
		} else {
			pfs[2] = 1
		}
		//pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i]++
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		if _, ok := pfs[n]; ok {
			pfs[n]++
		} else {
			pfs[n] = 1
		}
	}

	return pfs
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var S string

func main() {
	sc.Split(bufio.ScanWords)

	S = nextStr()
	ans := ""
	for i := 0; i < len(S); i++ {
		cur := string(S[i])
		if cur == "B" {
			if len(ans) > 0 {
				ans = ans[:len(ans)-1]
			} else {
				ans = ""
			}
			continue
		}
		ans += cur
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int h, w, c;
int ans;
map<pair<int, int>, bool> visited;

void dfs(vector<vector<int>> &p, int y, int x, int now, int next)
{
    if (visited[{y, x}] == true)
    {
        return;
    }
    visited[{y, x}] = true;
    p[y][x] = next;
    rep(i, 4)
    {
        if (p[y + dy[i]][x + dx[i]] == now)
        {
            dfs(p, y + dy[i], x + dx[i], now, next);
        }
    }
}

int count(vector<vector<int>> &p, int y, int x, int col)
{
    if (visited[{y, x}] == true)
        return 0;
    visited[{y, x}] = true;

    int ret = 0;
    //  cerr << y << "," << x << endl;
    // cerr << p.size() << "," << p[0].size() << endl;
    //cerr << "start if" << endl;
    if (p[y][x] == col)
    {
        ret++;
    }
    else
    {
        return 0;
    }
    //  cerr << "end if" << endl;

    rep(i, 4)
    {
        //   cerr << "loop" << i << endl;
        //cerr << y + dy[i] << "," << x + dx[i] << "," << c << endl;
        //cerr << p[y + dy[i]][x + dx[i]] << endl;
        //  if (y + dy[i] >= 0 && y + dy[i] < p.size() && x + dx[i] >= 0 && x + dx[i] < p[0].size())
        ret += count(p, y + dy[i], x + dx[i], col);

        //   cerr << "ok" << i << endl;
    }

    return ret;
}

int dfs2(vector<vector<int>> p, int n)
{
    if (n == 4)
    {
        visited.clear();
        dfs(p, 1, 1, p[1][1], c);
        visited.clear();
        return count(p, 1, 1, c);
    }
    auto back = p;
    int ret = -1;
    rep(i, 6)
    {
        visited.clear();
        dfs(p, 1, 1, p[1][1], i + 1);
        ret = max(ret, dfs2(p, n + 1));
        p = back;
    }
    return ret;
}

int main()
{
    while (true)
    {
        ans = -1;
        cin >> h >> w >> c;
        if (h == 0 && w == 0 && c == 0)
            break;
        vector<vector<int>> p(10, vector<int>(10, -1));
        rep(i, h)
            rep(j, w)
        {
            int t;
            cin >> t;
            p[i + 1][j + 1] = t;
        }
        cout << dfs2(p, 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
/* Fairy dandy tickling the fancy of his lady friend */

#include <iostream>

#include <vector>

#include <algorithm>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

#define rep(i,a,b) for(int i=int(a); i<int(b); i++)

#define rip(i,a,b) for(int i=(int)a; i>=(int)b; i--)

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

#define sz(x) int(x.size())

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

#define trace(x) cerr << #x << ": " << x <<endl;



using namespace std;



typedef long long int lli;

typedef pair<lli, lli> ii;

typedef vector<int> vi;

typedef vector<ii> vii;


const int N = 1e5+5;

lli A[N];
lli ans[N];


int main(){

    fastio;
    int n; cin>>n;

	rep(i,0,n) cin>>A[i];
	lli acum=0;
	rep(i,0,n-2) acum+= (i&1 ? -A[i]:A[i]);
	ans[n-1]=A[n-2]+A[n-1]-acum;
	rip(i,n-2,0) ans[i] = (2*A[i]-ans[i+1]);
	rep(i,0,n) cout<<ans[i]<<" ";
	cout<<endl;

    return 0;

}

Measured memory_bytes: 2944
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N : usize, K : usize,
    }

    let mut r = 0f64;
    for n in 1..N + 1 {
        let (mut t, mut c) = (n, 0usize);
        while t < K {
            t *= 2;
            c += 1;
        }
        r += (1f64 / N as f64) * (0.5f64).powf(c as f64);
        //println!("{} {} {}", r, c, (0.5f64).powf(c as f64));
    }
    println!("{}", r);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef vector <vector <ll>> vvl;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;
vi v;

void read() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.pb(x - i - 1);
  }
}
void solve() {
  ll sol = 0;
  sort(v.begin(), v.end());
  int b = v[n / 2];
  for(auto x : v)
    sol += abs(x - b);
  cout << sol << "\n";
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve(); 
  }
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    string s; cin >> s;
    s = "#" + s + "#";
    n = (int)s.size();
    
    bool flag = true;
    for(int i = a; i <= c; i++){
        if(s[i] == '#' && s[i + 1] == '#') flag = false;
    }

    for(int i = b; i <= d; i++){
        if(s[i] == '#' && s[i + 1] == '#') flag = false;
    }

    if(!flag){
        cout << "No" << endl;
        return 0;
    }
    
    if(c < d){
        cout << "Yes" << endl;
        return 0;
    }else{
        
        flag = false;

        for(int i = b - 1; i < d; i++){
            if(s[i] == '.' && s[i + 1] == s[i] && s[i + 2] == s[i]) flag = true;
        }

        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 772
import collections
h,w = map(int,input().split())
c = []
wall = []


def judge(num):
    koho = collections.deque()
    for i in range(10):
        if dp[i] > dp[num] + c[i][num]:
            koho.append(i)
            dp[i] = dp[num] + c[i][num]
    if koho:
        here = koho.popleft()
        judge(here)



for i in range(10):
    c.append(list(map(int,input().split())))
for i in range(h):
    wall.extend(list(map(int,input().split())))
wall = collections.Counter(wall)
dp = [0] * 10
for i in range(10):
    dp[i] = c[i][1]
for i in range(10):
    judge(i)
ans = 0
wall = list(wall.items())
for i in range(len(wall)):
    if wall[i][0] == -1:
        pass
    else:
        ans += dp[wall[i][0]] * wall[i][1]
print(ans)





Measured memory_bytes: 3828
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
	
	void Solve() {
		UL a, b; a = b = 0;
		UL n; cin >> n;
		UL P[8], Q[8];
		rep(i, n) { cin >> P[i]; P[i]--; }
		rep(i, n) { cin >> Q[i]; Q[i]--; }
		UL Pbuf[8] = {}, Qbuf[8] = {};
		UL S = 1;
		rep(i, n) {
			UL ii = n - i - 1;
			a += Pbuf[P[ii]] * S;
			b += Qbuf[Q[ii]] * S;
			for (UL j = P[ii]; j < n; j++) Pbuf[j]++;
			for (UL j = Q[ii]; j < n; j++) Qbuf[j]++;
			S *= (i + 1);
		}
		cout << max(a, b) - min(a, b) << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

const long long INF = 1LL<<50;
long long **d;
void init(int V) {
  d = new long long* [V];
  for (int i = 0; i < V; i++) {
    d[i] = new long long [V];
    for (int j = 0; j < V; j++)
      d[i][j] = i == j ? 0 : INF;
  }
}

void WarshallFloyd(int V) {
  for (int k = 0; k < V; k++)
    for (int i = 0; i < V; i++)
      for (int j = 0; j < V; j++)
        if (d[i][k] != INF && d[k][j] != INF)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

void terminate(int V) {
  for (int i = 0; i < V; i++)
    delete d[i];
  delete d;
}

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

  int V, E;
  cin >> V >> E;

  init(V);

  // input costs
  for (int i = 0; i < E; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    d[s][t] = c;
  }

  WarshallFloyd(V);

  for (int i = 0; i < V; i++) {
    if (d[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      terminate(V);
      return 0;
    }
  }

  for (int i = 0; i < V; i++) {
    if (d[i][0] == INF)
      cout << "INF";
    else
      cout << d[i][0];
    for (int j = 1; j < V; j++)
      if (d[i][j] == INF)
        cout << " INF";
      else
        cout << ' ' << d[i][j];
    cout << endl;
  }

  terminate(V);
}



Measured memory_bytes: 3256
import Foundation
 
// 入力
let input = readLine()!
let split = input.componentsSeparatedByString(" ")
let a = Int(split[0])! 
let b = Int(split[1])!
let c = Int(split[2])!
 
// 条件
let isOnTheWay = (a < c && c < b) || (a > c && c > b)
 
// 出力
print(isOnTheWay ? "Yes" : "No")

Measured memory_bytes: 7400
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    ll c;
    cin>>c;
    string s;
    cin >> s;
    if (s.size() % 2 == 1)
    {
        cout << "No" << endl;
    }
    else
    {
        string temp = s.substr(0, c / 2);
        string temp2 = s.substr(c / 2, c / 2);
        if (temp == temp2)
        {
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256