akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N;
  cin>>N;
  int ans=0;
  REP(i,N+1){
    REP(j,N+1){
      REP(k,N+1){
        ans+=gcd(gcd(i,j),k);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3580
inpl = lambda: list(map(int,input().split()))
N = int(input())
a = inpl()
s = [0]*N
for i in range(N,0,-1):
    s[i-1] = (sum(s[d*i-1] for d in range(2,N//i+1)) + a[i-1])  % 2
print(sum(s))
ans = " ".join([ str(i+1) for i in range(N) if s[i] ])
if len(ans) > 0:
    print(ans)

Measured memory_bytes: 80860
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007



using namespace std;

int main()
{
  ll H,res1=1,res=1,logRes;
  cin>>H;
  logRes=log2(H);
  if(logRes==0){cout<<1;return 0;}
  for(int i=0;i<logRes ; i++){
    res1*=2;
    res+=res1;
  }
cout<<res;
  return 0 ;
}


Measured memory_bytes: 768
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scan=new Scanner(System.in);
String mark;
int c=0;
int b=0;
int a[]=new int[100000];
int x=0;
do{c=scan.nextInt();
mark=scan.next();
b=scan.nextInt();	
	if(mark.equals("?")){
		a[x]=2000001;
		break;
	}
	else if(mark.equals("+")){
		a[x]=c+b;
	}
	else if(mark.equals("-")){
		a[x]=c-b;
	}
	else if(mark.equals("*")){
		a[x]=c*b;
	}
	else if(mark.equals("/")){
		a[x]=c/b;
	}
	x++;
}while(true);
x=0;
do{
	if(a[x]==2000001)break;
	System.out.println(a[x]);
	x++;
}while(true);
scan.close();
	}
}

Measured memory_bytes: 26664
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll dp[1<<12];

int main()
{ios_base::sync_with_stdio(false);
int n,m;
cin>>n>>m;

rep(i,0,(1<<n)-1)dp[i]=1e9+7;
dp[0]=0;

while(m--)
{
	int m1=0;
	int cst,sz;
	cin>>cst>>sz;
	rep(i,0,sz-1)
	{
		int x;
		cin>>x;
		x--;
		m1|=(1<<x);
	}
	rep(msk,0,(1<<n)-1)
	{
		dp[m1|msk]=min(dp[m1|msk],dp[msk]+cst);
	}
}

if(dp[(1<<n)-1]>=1e9)
{
	ol("-1");
	return 0;
}
ol(dp[(1<<n)-1]);
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
typedef long long ll;
int memo[maxn][2],A[105],N,mn = INT_MAX,K;
int solve(int rem,bool x){
    if (rem < mn){
        if (x)return 1;
        return 0;
    }
    int &ans = memo[rem][x];
    if (ans != -1)return ans;
    ans = 0;
    int cnt = 0;
    int z =0;
    for (int i = 1; i <= N;i++){
        if (A[i]>rem)continue;
        z++;
        int aux = solve(rem-A[i],!x);
        cnt+=aux;
        ans|=aux;
    }
    if (x && cnt == z)return (ans = 1);
    if (x)return (ans = 0);
    if(!x && !cnt)return (ans = 0);
    if (!x)return (ans = 1);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> K;
    for (int i = 1; i <= N;i++){
        cin >> A[i];
        mn= min(mn,A[i]);
    }
    memset(memo,-1,sizeof memo);
    if (solve(K,0))
        cout << "First";
    else
        cout << "Second";

    return 0;
}


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

int N, A, B, C, D;
vector<bool> blocked;

bool canReach(int s, int d) {
    while (s < d) {
        if (s+1 < N && !blocked[s+1]) s+=1;
        else if (s+2 < N && !blocked[s+2]) s+=2;
        else break;
    }
    return s == d;
}

int main() {
    
    cin >> N >> A >> B >> C >> D;
    blocked.resize(N);
    bool canOvertake = false;
    for (int i=0; i < N; ++i) {
        char a;
        cin >> a;
        if (a == '#') blocked[i] = true;
        
        if (i >=2) {
            int j;
            for (j=i; i-j < 3; --j) {
                if (blocked[j]) break;
            }
            
            if (i-j >= 3) {
                canOvertake = canOvertake || (i-1 >= B-1  && i-1 <= D-1);
            }
        }
    }
    
    if ((C < D || canOvertake ) && canReach(A-1, C-1) && canReach(B-1, D-1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a,b+1):
  if b-a>=674:
    c=1
    break
  elif i%673==0:
    c=1
    break
ll=[]
if b-a==1:
  print(a*b%2019)
elif c==1:
  print(0)
elif b-a>=102:
  print(1)
elif b-a>=48:
  print(2)
else:
  for i in range(a,b):
    for j in  range(i+1,b+1):
      ll.append(i*j%2019)
  print(min(ll))


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int K;
	long long A, B;
	cin >> A >> B >> K;
	
	if(B-A+1>2*K){
		for(int i=0; i<K; i++){
			cout << A+i << endl;
		}
		for(int i=K-1; i>=0; i--){
			cout << B-i << endl;
		}
	}else{
		for(int i=A; i<=B; i++){
			cout << i << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())

found = False
for a in range(n+1):
    for b in range(n-a+1):
        c = n - a - b
        total = 10000 * a + 5000 * b + 1000 * c
        if total == y:
            found = True
            print(a, b, c)
            break
    if found:
        break

if not found:
    print('-1 -1 -1')

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

bool isSorted(vector<int> v) {
    bool ok=(v.size()>1);
    for(int i=0; i<v.size(); i++) ok *= (v[i] == i+1);
    return ok;
}

int main()
{
    int N;
    vector<int> b;
    while(cin>>N, N) {
        b.resize(N);
        for(int i=0; i<N; i++) cin>>b[i];
        int ans=0;
        while(!isSorted(b) && ans<=10000) {
            ans++;
            b.push_back(N);
            for(int i=0; i<N; i++) {
                b[i]--;
                if(b[i]==0) {
                    b.erase(b.begin()+i);
                    N--;
                    i--;
                }
            }
            N++;
        }
        if(ans>10000) ans = -1;
        cout<<ans<<endl;
    }
}

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

using namespace std;
int ind[105];
pair<long long,long long > D[105];
int main(){
    srand(time(0));
    auto start = chrono::system_clock::now();

    int n;cin >> n;
    for(int i=1;i<=n;++i){
        cin >> D[i].first >> D[i].second;
        ind[i]=1;
    }
    long long x,y;x=0;y=0;
    int cnt2=0;
    double ans=0;
    while(1){
        bool flag=0;

        for(int i=1;i<=n;++i){
            long long X=x+D[i].first*ind[i];
            long long Y=y+D[i].second*ind[i];
            if(X*X+Y*Y>x*x+y*y){
                flag=1;
                x=X;y=Y;
                ind[i]*=-1;
                
            }
        }
        if(!flag){
            ans=max(ans,sqrt(x*x+y*y));
            x=0;y=0;
            auto en = std::chrono::system_clock::now();
            chrono::duration<double> elapsed= en-start;
            if(elapsed.count()>1.99){
                break;
            }
            for(int i=1;i<=n;++i){
                int u=rand();
                if(u&1){
                    x+=D[i].first;
                    y+=D[i].second;
                    ind[i]=-1;
                }
                else{
                    ind[i]=1;
                }
            }
        }
    }
    printf("%.16f\n",ans);

    return 0;

}


Measured memory_bytes: 256
import sys
import bisect

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
MOD = 10 ** 9 + 7
A = lr(); A.sort()
B = lr(); B.sort()
if len(set(A)) != N or len(set(B)) != M or min(A) < M or min(B) < N:
    print(0); exit() 
Aset = set(A)
Bset = set(B)
total_set = Aset | Bset
answer = 1

for x in total_set:
    if x in Aset and x in Bset:
        continue
    if x in Aset:
        i = bisect.bisect_left(B, x)
        answer *= (M - i)
    else:
        i = bisect.bisect_left(A, x)
        answer *= (N - i)
    answer %= MOD


remain_set = set(range(1, N*M+1)) - total_set
remain = sorted(list(remain_set), reverse=True)

# 残った物を大きい順に決めていく
for x in remain:
    ai = bisect.bisect_left(A, x)
    bi = bisect.bisect_left(B, x)
    y = (N-ai) * (M-bi) - (N*M - x)
    answer *= y
    answer %= MOD
    
print(answer)
#46

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

#define NIL NULL

struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

typedef struct node * Nodep;

void insert(int);
void preorder(Nodep);
void inorder(Nodep);

Nodep root;


int main(){

  Nodep z;
  int key,n,i,x;
  char op[7];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%s",op);

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



void insert(int k){
  Nodep y = NIL;
  Nodep x = root; 
  Nodep z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent= y;
  if(y==NIL){
    root = z;
  }
  else if(z->key<y->key){
    y->left =z;
  }
  else{
    y->right =z;
  }
}

void inorder(Nodep A){
  if(A != NIL){
    inorder(A->left);
    printf(" %d",A->key);
    inorder(A->right);
  }
}
   
void preorder(Nodep A){
  if(A!=NIL){
    printf(" %d",A->key);
    preorder(A->left);
    preorder(A->right);
  }
}

Measured memory_bytes: 24040
N = int(input())
a = list(map(int, input().split()))

b = [0]*N

if N%2 == 0:
    for i in range(N):
        if i % 2 != 1:
            b[N//2+i//2] = a[i]
        else:
            b[N//2-i//2-1] = a[i]
else:
    for i in range(N):
        if i % 2 != 1:
            b[N//2-i//2] = a[i]
        else:
            b[N//2+i//2+1] = a[i]

ans = ' '.join(list(map(str, b)))
print(ans)

Measured memory_bytes: 29768
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;

void game(int num)
{
	int i, taro = 0, hanako = 0;
	string tcard, hcard;
	for (i = 0; i < num; i++)
	{
		cin >> tcard >> hcard;
		if (tcard > hcard) taro += 3;
		else if (tcard < hcard) hanako += 3;
		else
		{
			taro++;
			hanako++;
		}
	}
	cout << taro << " " << hanako << endl;
}

int main()
{
	int num;
	cin >> num;
	game(num);
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<int,int> P;
int main(void) {
    int n, k; cin >> n >> k;
    double ans = 0;
    for(int i=1;i<=n;i++) {
        if(i<k)
            ans += pow(0.5, ceil(log2((double)k/i)));
        else
            ans += 1.0;
    }
    printf("%.10f\n",ans/n);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

int main(void)
{
	char s[1+2];

	while(scanf("%1[A-Za-z]\n", s)==1)
	{
		int ans='A';
		if(islower(s[0])) ans='a';
		printf("%c\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define For(x,y,z) for(int x = y ; x <= z ; x++)
#define ll long long
int f[100001];
ll n, m, k;
inline int Read(){
	int a = 0, w = 1;
	char c;
	for(c = getchar() ; c < '0' || c > '9' ; c = getchar())
		if(c == '-') w = -1;
	for(c ; c >= '0' && c <= '9' ; c = getchar())
		a = (a << 1) + (a << 3) + c - '0';
	return a * w; 
}
int main(){
	n = Read();
	m = Read();
	k = Read();
	n -= m;
	n %= k;
	cout << n;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long ans = 0;
		if(N%2==0){
			ans += N/10;
			ans += N/50;
			long b = 50;
			while(true){
				b = b * 5;
				if(b>N){
					break;
				}
				ans += N/b;
				if(b>=Math.Pow(10,18)){
                  	break;
                }
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        char[] s = scanner.next().toCharArray();
        int n = s.length;
        int[] ans = new int[n];
        for (int i = 0; i < n; ) {
            int j;
            for (j = i; j < n && s[j] == 'R'; ++j) ;
            int rNum = j - i;
            int rEnd = j - 1;
            i = j;
            for (; j < n && s[j] == 'L'; ++j) ;
            int lNum = j - i;
            int lEnd = i;
            i = j;
            ans[rEnd] = rNum / 2 + rNum % 2 + lNum / 2;
            ans[lEnd] = lNum / 2 + lNum % 2 + rNum / 2;
        }
        for (int i = 0; i < n; ++i)
            writer.print(ans[i] + " ");
        writer.println();
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 35884
import java.util.*;

public class Main {

    public static class Arm {
        long x;
        long l;
        long min;
        long max;
        long distance;
        public Arm( long x , long l ){
            this.x = x;
            this.l = l;
            this.min = x - l;
            this.max = x + l;
            this.distance = this.max - this.min;
        }
    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt( in.nextLine() );
        List<Arm> arms = new ArrayList<>();
        for( int i = 0 ; i < n ; i++ ){
            String[] params = in.nextLine().split(" ");
            arms.add( new Arm( Long.parseLong( params[0] ) , Long.parseLong( params[1] ) ) );
        }

        arms.sort( (o1, o2) -> {
            if( o1.min < o2.min ){
                return -1;
            }
            if( o1.min == o2.min ){
                return 0;
            }
            return 1;
        } );

        for( int i = 0 ; i < arms.size() - 1 ; i++ ) {
            Arm iArm = arms.get(i);
            Arm jArm = arms.get(i + 1);
            if (iArm.max <= jArm.min) {
                continue;
            }
            if (iArm.max <= jArm.max) {
                arms.remove(i+1);
                i--;
                n--;
                continue;
            }
            arms.remove(i);
            i--;
            n--;
        }

        System.out.println( n );

    }

}


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

int main() 
{
  vector<int> input;
  int inp;
  for(int i=0;i<3;i++)
  {
    cin>>inp;
    input.push_back(inp);
  }
  sort(input.begin(),input.end());
  cout<<input[0]+input[1]<<endl;
  return 0;
}
  

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int s = 0;
    for (; a <= b; a++) {
        if (c % a == 0) {
            s++;
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>

#define N 100
#define NIL -1

int Pre(int t);
int In(int t);
int Post(int t);

struct Node{
  int p, left, right;
};
struct Node A[N];

int main(){
 
  int i, j;
  int n, id, h, d;
 
  scanf("%d", &n);
   
  for(i = 0; i < n; i++){
   A[i].p = NIL;
   A[i].left = NIL;
   A[i].right = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &id, &h, &d);
    A[h].p = id;
    A[d].p = id;
    A[id].left = h;
    A[id].right = d;
  }
  for(i = 0; i < n; i++){
    if(A[i].p == NIL){
      break;
    }
  }

  printf("Preorder\n");
  Pre(i);
  printf("\n");
    
  printf("Inorder\n");
  In(i);
  printf("\n");
    
  printf("Postorder\n");
  Post(i);
  printf("\n");
 
  return 0;
}
 
int Pre(int t){

  printf(" %d",t);

  if(t != NIL){
    if(A[t].left != NIL)Pre(A[t].left);

    if(A[t].right != NIL)Pre(A[t].right);
  }
 return 0;
}
 
int In(int t){

  if(t != NIL){
    if(A[t].left != NIL){
      In(A[t].left);
    }
    printf(" %d",t);
      
    if(A[t].right != NIL){
      In(A[t].right);
    }
  }
  return 0;
}
  
int Post(int t){

  if(t != NIL){
    if(A[t].left != NIL)Post(A[t].left);

    if(A[t].right != NIL)Post(A[t].right);
  }
  printf(" %d",t);
  return 0;
}

Measured memory_bytes: 616
import java.util.Scanner;

/**
 * Greedy Takahashi
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long A = sc.nextLong();
            long B = sc.nextLong();
            long K = sc.nextLong();

            if (K <= A) {
                A -= K;
            } else if (K <= A + B) {
                B -= K - A;
                A = 0;
            } else {
                A = 0;
                B = 0;
            }

            System.out.println(A + " " + B);
        }
    }

}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string s;
	cin >> s;
	int ans = 0;
	rep(i, 0, 3)
	{
		if (s[i] == '1')ans++;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {

  int64_t X;
  cin >> X;
  const double rate = 0.01;
  int64_t capital = 100;

  int year = 0;
  while(X > capital){
    capital += rate*capital;
    year++;
  }

  cout << year << endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    int k = get<int>();

    if (k > (n-1)*(n-2)/2) {
        cout << -1 << endl;
    } else {
        int k1 = (n-1)*(n-2)/2;
        cout << (n - 2 + 1) + (k1 - k) << endl;
        for (int i = 2; i <= n; i++)
            cout << 1 << " " << i << endl;

        for (int i = 2; i <= n-1; i++) {
            for (int j = i+1; j <= n; j++) {
                if (k1 == k)
                    goto End;
                cout << i << " " << j << endl;
                k1--;
            }
        }
        End:;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

bool is_prime(ll n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i * i <= n; ++i)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n + 1, 0);
    a[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i * j > n)
                break;
            a[i * j]++;
        }
    }
    // debug_vec(a);
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += (a[i] + 1) * i;
    }
    cout << ans-1 << endl;
    // debug_vec(a);

    return 0;
}

Measured memory_bytes: 81404
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

void dfs(vector<vector<ll>>& graph,vector<bool> done, int v, ll& ans) {
  int n = done.size();
	bool ok = true;
	done[v] = true;
	rep(i, n) ok &= done[i];

	if (ok) ans++;
	else {
		for (int w : graph[v]) {
			if (!done[w]) dfs(graph, done, w, ans);
		}
	}

}

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

	ll n, m; cin >> n >> m;
	vector<vector<ll>> graph(n, vector<ll>());
	rep(i, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	ll ans = 0;

	vector<bool> done(n,false);

	dfs(graph, done, 0, ans);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(100100,0),dp(100100,0);
  rep(i,n){cin>>a[i];}
  dp[1]=abs(a[0]-a[1]);
  REP(i,2,n){dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));}
  cout<<dp[n-1]<<endl;
}

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


def solve(S: str):
    print(700 + 100 * S.count("o"))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>

#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}

struct pt
{
    int x,y;
    pt(){}
    pt(int x,int y):x(x),y(y){}
};

int n;
vector<pt> p1,p2;

bool cmp1(pt a,pt b)
{
    return a.x+a.y<b.x+b.y;
}
bool cmp2(pt a,pt b)
{
    return a.x-a.y<b.x-b.y;
}

ll manh(pt a,pt b)
{
    return abs(a.x-b.x)+abs(a.y-b.y);
}

int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
    
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        p1.pb(pt(x,y));
        p2.pb(pt(x,y));
    }
    sort(all(p1),&cmp1);
    sort(all(p2),&cmp2);
    vector<pt> p;
    p.pb(p1[0]);
    p.pb(p2[0]);
    p.pb(p1.back());
    p.pb(p2.back());
    
    ll ans=0;
    for(int i=0;i<p.size();i++)
        for(int j=0;j<p.size();j++)
            ans=max(ans,manh(p[i],p[j]));
    
    cout<<ans<<endl;
    
    
    
    
}


Measured memory_bytes: 6328
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    int n, k, l, r, s, ans;
    l = 0, r = 1, s = 0;

    vector<int> v;
    cin >> n >> k;
    int a[n] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    s = a[0];
    while (l < n && r <= n)
    {
        if (s >= k)
        {
            v.push_back(r - l);
            s -= a[l];
            l++;
        }
        else
        {
            if (r < n)
            {
                s += a[r];
                r++;
            }
            else
                break;
        }
    }
    ans = 2 * n;
    for (auto itr = v.begin(); itr != v.end(); itr++)
    {
        ans = min(ans, *itr);
    }
    cout << ((ans == 2 * n) ? 0 : ans) << endl;

    return 0;
}


Measured memory_bytes: 3872
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int qsort_int(const void *a, const void *b)
{
    // 昇順
    return *(int *) a - *(int *) b;
}

int main(int argc, char *argv[])
{
    int n;
    int l[10];
    int i;
    int sum;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &l[i]);
    }

    qsort(l, n, sizeof(int), qsort_int);

    sum = 0;
    for (i = 0; i < n - 1; i++) {
        sum += l[i];
    }

    if (l[n - 1] < sum) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    static class Solver {
        private final long INF = (long) 1e18 + 1;
        private void solve(InputReader inp, PrintWriter out) {
            long a = inp.nextLong();
            long b = inp.nextLong();
            long c = inp.nextLong();
            long k = inp.nextLong();
            if (k % 2 == 0) {
                out.println(a - b);
            } else {
                out.println(b - a);
            }
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) n % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std; 

int main() { 
    IOS;
    ll N, W;
    cin >> N >> W;
    vll w(N + 1, 0);
    vll v(N + 1, 0);
    vector<vll> dp(N + 1, vll (W + 1, 0));
    for (int i = 1; i < N + 1; i++) {
    	cin >> w[i] >> v[i];
    	for (int j = 0; j < W + 1; j++) {
    		if (i == 0) {
    			dp[i][j] = (w[0] <= j)? w[0]: 0;
    			continue;
    		}
    		if (j >= w[i]) {
    			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
    		} else {
    			dp[i][j] = dp[i - 1][j];
    		}
    	}
    }
    cout << dp[N][W] << endl;
    
}   

Measured memory_bytes: 80256
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
#define gcd __gcd

using namespace std;

typedef pair<int, int> pii;

const int MAX = 100;
int n, m, deg[MAX];

int main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 0 ; i < m ; i++){
        int u, v;
        cin >> u >> v;
        deg[u]++;
        deg[v]++;
	}
	for (int i = 1 ; i <= n ; i++)      cout << deg[i] << endl;
}

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

using P = pair<double, int>;

int main()
{
	cout << fixed << setprecision(2);
	vector<int> p(8);
	vector<double> t(8);
	set<P> s;
	for (int j = 0; j < 3; j++) {
		int n1, n2;
		double t1 = 1000, t2 = 1000;
		for (int i = 0; i < 8; i++) {
			cin >> p[i] >> t[i];
			s.insert((P(t[i], p[i])));
			if (t1 > t[i]) {
				t2 = t1;
				n2 = n1;
				t1 = t[i];
				n1 = i;
			}
			else if (t2 > t[i]) {
				t2 = t[i];
				n2 = i;
			}
		}
		cout << p[n1] << ' ' << t[n1] << endl;
		cout << p[n2] << ' ' << t[n2] << endl;
		s.erase(P(t[n1], p[n1]));
		s.erase(P(t[n2], p[n2]));
	}
	cout << s.begin()->second << ' ' << s.begin()->first << endl;
	s.erase(s.begin());
	cout << s.begin()->second << ' ' << s.begin()->first << endl;
	return 0;
}

Measured memory_bytes: 3216
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(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 ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int a, b;
    cin >> a >> b;
    int res = 0;
    FOR(i, a, b) {
        string s1 = to_string(i);
        string s2 = to_string(i);
        reverse(s1.begin(), s1.end());
        if (s1 == s2) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

//all defines
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;


#define pb push_back
#define INF 2e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 2001
#define acmpIN "input.txt"
#define acmpOUT "output.txt"
#define IN "input.in"
#define OUT "output.out"
#define ff first
#define ss second


/**
    CHANGE SIZE!!!
**/

int a, b;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT,"w", stdout);


    cin >> a >> b;
    b *= 10;
    for(int i = 0; i <= 9; i++)
    {
        int cur = b + i;
        int x = cur * 0.08;
        if(x == a)
        {
            cout << cur;
            return 0;
        }
    }

    cout << -1;

    return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, v, p int
	fmt.Scan(&n, &m, &v, &p)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(as)))

	ok, ng := 0, n
	for ng-ok > 1 {
		mid := (ok + ng) / 2
		if check(as, mid, m, v, p) {
			ok = mid
		} else {
			ng = mid
		}
	}
	fmt.Println(ok + 1)
}

func check(as []int, x, m, v, p int) bool {
	xv := as[x] + m
	if as[p-1] > xv {
		return false
	}

	pp := 0
	for i := 0; i < len(as); i++ {
		if i < p-1 || x <= i {
			pp += m
		} else {
			if as[i] < xv {
				pp += xv - as[i]
			}
		}
	}

	return m*v <= pp
}


Measured memory_bytes: 5504
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<25) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M;
    while (cin>>N>>M, N|M) {
        vector<vector<int>> dl(N, vector<int>(N, INF));
        vector<vector<int>> ds(N, vector<int>(N, INF));
        for(int i=0; i<N; i++)
            dl[i][i] = ds[i][i] = 0;
        
        for(int i=0; i<M; i++){
            int x, y, t;
            char sl;
            cin >> x >> y >> t >> sl;
            x--; y--;
            if(sl == 'L'){
                dl[x][y] = min(dl[x][y], t);
                dl[y][x] = min(dl[y][x], t);
            }else{
                ds[x][y] = min(ds[x][y], t);
                ds[y][x] = min(ds[y][x], t);
            }
        }
        int R; cin >> R;
        vector<int> z(R);
        for(auto &r: z){
            cin >> r; r--;
        }
        for(int k=0; k<N; k++){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
                    dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
                }
            }
        }
        
        // dp[i][j] := j?????????????????¶?????§z[i]?????§??\?????????????°??????????
        vector<vector<int>> dp(R, vector<int>(N, INF));
        for(int i=0; i<N; i++)
            dp[0][i] = ds[z[0]][i] + dl[i][z[0]];
        
        for(int i=1; i<R; i++){
            for(int j=0; j<N; j++){
                for(int k=0; k<N; k++){
                    if(j == k)
                        dp[i][j] = min(dp[i][j], dp[i-1][j] + dl[z[i-1]][z[i]]);
                    else
                        dp[i][j] = min(dp[i][j], dp[i-1][k] + dl[z[i-1]][k] + ds[k][j] + dl[j][z[i]]);
                }
            }
        }
        
        int ans = INF;
        for(int i=0; i<N; i++)
            ans = min(ans, dp[R-1][i]);
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2324
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 7;
int lst[Max];

int main()
{
	int n;
	cin >> n;
	int f = 0;
	for (int i = 1; i <= n; i++)scanf("%d", &lst[i]);
	int k = lst[1];
	for (int i = 1; i <= Max; i++)
	{
		if (k == 2)
		{
			f = i; break;
		}
		k = lst[k];
	}
	if (f) cout << f;
	else cout << -1;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <malloc.h>
int main()
{
	int m, n, x;
	scanf("%d %d %d", &n, &m, &x);
	m = m + n + x;
	if (m < 22) {
		printf("win");
	}
	else {
		printf("bust");
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
const int N=20;
const int MAXN=1<<16;
const int INF=1e9+10;;
int min(int a,int b){return a>b?b:a;}
int main(){
    int n,dis[N][N],m,l,r,w,dp[MAXN][N],ans=INF,all;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)dis[i][j]=INF;
    while(m--){
        scanf("%d%d%d",&l,&r,&w);
        dis[l][r]=w;
    }
    all=1<<n;
    dp[0][0]=0;
    for(int i=1;i<all;i++)for(int j=1;j<n;j++)if(i&(1<<j)){
        if(i==1<<j)dp[i][j]=dis[0][j];
        else{
            dp[i][j]=INF;
            for(int k=0;k<n;k++)if(k!=j&&i&(1<<k))dp[i][j]=min(dp[i][j],dp[i-(1<<j)][k]+dis[k][j]);
        }
    }
    for(int i=1;i<n;i++)ans=min(ans,dp[all-2][i]+dis[i][0]);
    if(ans==INF)printf("-1\n");
    else printf("%d\n",ans);
}


Measured memory_bytes: 5144
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 1; i <= N; i++) {
            A[i-1] = sc.nextLong() - i;
        }

        Arrays.sort(A);

        long b;
        if (N % 2 == 0) {
            b = Math.round((A[N/2] + A[N/2 - 1]) / 2.0);
        } else {
            b = A[(N - 1) / 2];
        }

        long ret = 0;
        for (int i = 0; i < N; i++) {
            ret += Math.abs(A[i] - b);
        }

        System.out.println(ret);
    }
}

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> A(n), B(n);
    for (int i = 0; i < n; ++i)
      cin >> A[i] >> B[i];
    int scoreA = 0, scoreB = 0;
    for (int i = 0; i < n; ++i) {
      if (A[i] == B[i])
        scoreA += A[i], scoreB += B[i];
      else if (A[i] < B[i])
        scoreB += A[i] + B[i];
      else
        scoreA += A[i] + B[i];
    }
    cout << scoreA << " " << scoreB << endl;
  }
}

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

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

    string b; cin >> b;
    if (b == "A") {
        cout << 'T' << endl;
    } else if (b == "T") {
        cout << 'A' << endl;
    } else if (b == "C") {
        cout << 'G' << endl;
    } else {
        cout << 'C' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int N,K;
ll t[100010];
ll d[100010];

int main ()
{
    cin >> N >> K;
    REP(i,N) cin >> t[i] >> d[i];

    vector < pair < ll, ll > > ord;
    REP(i,N) ord.push_back(make_pair(d[i], i));
    sort(ord.begin(), ord.end());
    reverse(ord.begin(), ord.end());

    ll sum = 0;
    vector < ll > cnd;
    reversed_priority_queue < pair < ll, ll > > que1;
    priority_queue < pair < ll, ll > > que2;
    bool used[100010] = {};
    ll x2 = 0;
    REP(i,K) {
        ll idx = ord[i].second;
        ll del = ord[i].first;
        ll tt = t[idx];
        if (!used[tt]) {
            used[tt] = true;
            x2++;
        } else {
            que1.push(make_pair(d[idx], t[idx]));
        }
        sum += del;
    }
    for (int i = K; i < N; i++) {
        ll idx = ord[i].second;
        ll tt = t[idx];
        if (!used[tt]) {
            used[tt] = true;
            que2.push(make_pair(d[idx], t[idx]));
        }
    }

    cnd.push_back(sum + x2 * x2);
    while ((!que1.empty()) && (!que2.empty())) {
        sum -= que1.top().first;
        sum += que2.top().first;
        que1.pop();
        que2.pop();
        x2++;
        cnd.push_back(sum + x2 * x2);
    }

    ll ans = 0;
    REP(i,cnd.size()) {
        ans = max(ans, cnd[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5360