akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const int N = 10;

void insertionSort(int *a, int n) {
  int v, j;
  for (int i=0; i<n; i++) {
    v = a[i];
    j = i - 1;
    while (0<=j && v<a[j]) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

    // for (int k=0; k<n; k++) {
    //   cout << a[k];
    //   if (k < n - 1) cout << " ";
    // }
    // cout << endl;
  }
}

int main() {
  int height[N];
  for (int i=0;i<N;i++) {
  	cin >> height[i];
  }
  insertionSort(height, N);

  int h = 3;
  for (int i=N-1;i>N-h-1;i--) {
  	cout << height[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int a,b,c; cin>>a>>b>>c;
	swap(a,b); swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  if(s[0]==s[1] || s[1]==s[2] || s[2]== s[3]){
    cout << "Bad" << endl;
  }
  else cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

ll modinv(ll x, ll m = mod) {
  ll b = m;
  ll u = 1;
  ll v = 0;
  ll tmp;
  while (b) {
    ll t = x / b;
    x -= t * b;
    tmp = x;
    x = b;
    b = tmp;
    u -= t * v;
    tmp = u;
    u = v;
    v = tmp;
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}


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

  ll k;
  cin >> k;
  string s;
  cin >> s;

  ll n = s.size();

  vector<ll> factorial(2000001);
  factorial[0] = 1;
  for (ll i = 1; i <= 2000000; i++) {
    factorial[i] = (factorial[i-1] * i) % mod;
  }

  vector<ll> kn1ck(k+1);
  for (ll i = 0; i <= k; i++) {
    kn1ck[i] = (factorial[i+n-1] * (modinv((factorial[n-1] * factorial[i]) % mod))) % mod;
  }

  ll factor = 1;
  for (int i = 0; i < k; i++) {
    factor = (factor * 26) % mod;
  }

  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    ans = (ans + (factor * kn1ck[i]) % mod) % mod;
    factor = (((factor * modinv(26)) % mod) * 25) % mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 27752
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int main()
{
	int M, D, m, d;
	cin >> M >> D >> m >> d;
	if (M != m) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(n) for (int i = 0; i < n; ++i)
#define ps(x) cout << x << endl;
#define ps_end(x) ps(x); return;

const int md = 1e9 + 7; //998244353 ;
void addto(int &x, int y) { x = x + y; if (x >= md) x -= md; }
int add(int x, int y) { int z = x + y; return z >= md? z -= md : z;}
void updmin(auto&x, auto y ) { if (y < x) x = y;}
void updmax(auto&x, auto y ) { if (y > x) x = y;}
long long pw(auto x, auto y) {	
	long long s = 1;
	while(y) {
		if (y & 1) s = s * x % md;
		x= 1LL * x * x % md; y /= 2;
	}
	return s;
}


const int maxn = 1e6 + 10;

int T, n;
ll m;
void task() {
	cin >> n >> m;
	int ans = 0;
	rep(n) {
		
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= m * m) ans++;
	};
	ps_end(ans);
	
	
	// you should actually read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  T = 1;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


Measured memory_bytes: 3648
ABCD = list(input())

def dp(i, abcd, s):
  if i == 3:
    s += abcd[3]
    if eval(s) == 7:
      return s, True
    else:
      return s, False
  for c in ['+', '-']:
    d, f = dp(i + 1, abcd, s + abcd[i] + c)
    if f:
      return d, True
  else:
    return d, False

s, f = dp(0, ABCD, '')
print(s + '=7')

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

int main(void) {
  char D[410];
  int  M;
  while (1) {
    int m,d;
    scanf("%s\n", D); d=strlen(D);
    if (D[0] == '-') break;
    scanf("%d\n", &M);
    for (m=0;m<M;m++) {
      int n;
      scanf("%d\n", &n);
      strncat(D,D,n);
      memmove(D,D+n,d);
      D[d] = 0;
    }
    printf("%s\n",D);
  }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b){cout << c << endl;}
  else if(b == c){cout << a << endl;}
  else if(a == c){cout << b << endl;}

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] x = new int[n];
		for(int i=0; i<n; i++){
			x[i] = sc.nextInt();
		}
		sc.close();
		
		int[] rem = new int[n];
		int[] num = new int[m];
		int[] same = new int[200000 + m + 100];
		for(int i=0; i<n; i++){
			rem[i] = x[i]%m;
		}
		
		int ans = 0;
		
		for(int i=0; i<n; i++){
			num[rem[i]]++;
			same[x[i]]++;
		}
		ans += num[0]/2;
		for(int i=1; i<=(m-1)/2; i++){
			ans += Math.min(num[i], num[m-i]);
			int nsam = (Math.max(num[i], num[m-i]) - Math.min(num[i], num[m-i])) / 2;
			int p = 0;
			while(nsam > 0){
				if(num[i] > num[m-i]){
					if(same[p*m + i] >= 2){
						ans += Math.min(nsam, same[p*m+i]/2);
						nsam -= same[p*m+i]/2;
					}
				}
				if(num[i] < num[m-i]){
					if(same[p*m + m - i] >= 2){
						ans += Math.min(nsam, same[p*m+m-i]/2);
						nsam -= same[p*m+m-i]/2;
					}
				}
				if(p*m > 100000){
					break;
				}
				p++;
			}
		}
		
		if(m%2 == 0){
			ans += num[m/2]/2;
		}
		
		System.out.println(ans);

	}

}


Measured memory_bytes: 34112
def max_sub_square(m)
  row,col = m.size, m.first.size
  s = Array.new(row){Array.new(col,0)}
 
  # Set first column of S[][]
  for i in 0...row
    s[i][0] = m[i][0]
  end
  # Set first row of S[][]
  for j in 0...col
    s[0][j] = m[0][j]
  end
 
  # Construct other entries of S[][]
  for i in 1...row
    for j in 1...col
      if m[i][j] == 1
        s[i][j] = [ s[i][j-1], s[i-1][j], s[i-1][j-1] ].min + 1
      else
        s[i][j] = 0
      end
    end
  end
  # Find the maximum entry, and indexes of maximum entry in S[][]
  max_of_s,max_i,max_j = s[0][0],0,0
 
  for i in 0...row
    for j in 0...col
      if max_of_s < s[i][j]
        max_of_s,max_i,max_j = s[i][j],i,j
      end
    end
  end
 
  #printf "Maximum size sub-matrix is: \n"
  ans = 0
  max_i.downto(max_i - max_of_s + 1) do |i|
    max_j.downto(max_j - max_of_s + 1) do |j|
      #printf "%d", m[i][j]
      ans += m[i][j]
    end
    #puts ""
  end
  ans
end
 
lines = $stdin.read
array = lines.split("\n")
H,W = array[0].split(" ").map(&:to_i)
M = array[1..H].map do |str|
  str.split(" ").map(&:to_i).map do |n|
    if n==1
      0
    else
      1
    end
  end
end
 
p max_sub_square(M)


Measured memory_bytes: 46216
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }
        List<Integer> b = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            b.add(sc.nextInt());
        }
        List<Integer> c = new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            c.add(sc.nextInt());
        }

        int result = 0;
        int preIndex = -2;
        for (int i = 0; i < n; i++) {
            int index = a.get(i) - 1;
            result += b.get(index);
            if (preIndex == index - 1) {
                result += c.get(preIndex);
            }
            preIndex = index;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 22612
import java.util.Scanner;
	public class Main {
	 public static void main(String[] args) {
	 Scanner sc = new Scanner(System.in);
     int n = sc.nextInt();
     boolean h = false;
	for(int a=1; a<=9; a++){
      for(int b=1; b<=9; b++){
               if(a*b==n){
         h = true;
      }  
	 }
    }
      System.out.println(h?"Yes":"No");
	 }
	}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //int N = Integer.parseInt(scan.next());
        int H = Integer.parseInt(scan.next());
        int W = Integer.parseInt(scan.next());
        String[] C = new String[H];
        for(int i = 0;i<H;i++){
            C[i] = scan.next();
        }
        for(int i = 0;i<H;i++){
            System.out.println(C[i]);
            System.out.println(C[i]);
        }
    }
}

Measured memory_bytes: 23636
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long m=sc.nextLong();
		long k=sc.nextLong();
		long mod=1000000007;
		long count=0;
		for(int i=1; i<=m; i++){
			count+=((n*n)%mod)*((((m-i+1)*(m-i))/2)%mod);
			count%=mod;
		}
		for(int i=1; i<=n; i++){
			count+=((m*m)%mod)*((((n-i+1)*(n-i))/2)%mod);
			count%=mod;
		}
		System.out.println((count*Combination(n*m-2,k-2,mod))%mod);
	}
	static long Combination(long left,long right,long mod){
		long ans=1;
		right=Math.min(right,left-right);
		for(int i=0; i<right; i++){
			ans*=(left-i);
			ans%=mod;
		}
		for(int i=2; i<=right; i++){
			long tmp=mod-2;
			long mul=i;
			while(tmp>0){
				if((tmp&1)==1){
					ans*=mul;
				}
				tmp>>=1;
				mul*=mul;
				ans%=mod;
				mul%=mod;
			}
		}
		return ans;
	}
}




Measured memory_bytes: 23124
public class Main {


  private static void solve() {
    char[] s = ns();
    int cnt = 0;
    for (char c : s) {
      if (c == 'o') {
        cnt ++;
      }
    }
    
    if (cnt + (15 - s.length) >= 8) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23124
<?php
list($a,$b) = explode(" ",trim(fgets(STDIN)));
if($a < 0){
    if($b < 0){
        if(($b + $a) % 2 == 0){
            echo "Negative";
        }else{
            echo "Positive";
        }
    }else{
        echo "Zero";
    }
}elseif($a == 0){
    echo "Zero";
}else{
    echo "Positive";
}
?>

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, M; cin >> N >> M;
    vector<int> a(M), b(M);
    vector<int> s(M);
    int tmp;
    vector<ll> dp(1<<N, INF/2);
    dp[0] = 0;
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        s[i] = 0;
        for (int j = 0; j < b[i]; j++) {
            cin >> tmp; tmp--;
            s[i] += (1<<tmp);
        }
        for (int j = 0; j < (1<<N); j++) {
            int g = s[i] | j;
            dp[g] = min(dp[g], dp[j] + a[i]);
        }
    }


    if(dp[(1<<N) - 1] == INF/2){
        printf("%d\n", -1);
    }
    else{
        printf("%lld\n", dp[(1<<N) - 1]);
    }




}

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

int main()
{
	int n;
	cin >> n;
	int r, l, s = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> l >> r;
		s += r - l + 1;
	}
	cout << s << endl;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];
            var A = ReadArrayInt();

            for (int i = 0; i < K; i++)
            {
                var nextA = new int[N];
                for (int j = 0; j < N; j++)
                {
                    var min = Math.Max(j - A[j], 0);
                    var max = Math.Min(j + A[j], N - 1);
                    nextA[min]++;
                    if (max + 1 < N) nextA[max + 1]--;
                }
                for (int j = 1; j < N; j++) nextA[j] += nextA[j - 1];
                var chk = nextA.Distinct().ToArray();
                if (chk.Count() == 1 && chk[0] == N)
                {
                    Console.WriteLine(string.Join(" ", nextA));
                    return;
                }
                A = nextA;
            }

            Console.WriteLine(string.Join(" ", A));
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


Measured memory_bytes: 62616
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key)
      u=u->left;
    else
      u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)
    y=z;
  else
    y=treeSuccessor(z);

  if(y->left != NIL)
    x=y->left;
  else
    x=y->right;

  if(x!=NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right = x;
  if(y!=z)
    z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node 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(Node u){
  if(u==NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


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

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#python3

#cups for water, spoons for sugar
cup1, cup2, spoon1, spoon2, max_density, max_volume = (int(x) for x in input().split())

possible_water_volumes = set()

for cups1_nr in range(0, 30):
    for cups2_nr in range(0, 30):
        curr_water_volume = cups1_nr * cup1 + cups2_nr * cup2
        if curr_water_volume * 100 <= max_volume and curr_water_volume != 0:
            possible_water_volumes.add(curr_water_volume)

global_optimal_sugar = 0
global_optimal_water = cup1
global_dencity = 0            
for water_volume in possible_water_volumes:
    curr_optimal_sugar = min(water_volume * max_density, max_volume - water_volume * 100)
    for spoons1_nr in range(0, 1 + curr_optimal_sugar // spoon1):
        curr_sugar = spoon1 * spoons1_nr
        spoons2_nr = ((curr_optimal_sugar - curr_sugar) // spoon2)
        curr_sugar += spoon2 * spoons2_nr
        curr_density = curr_sugar / (water_volume * 100 + curr_sugar)
        if curr_sugar + water_volume * 100 > max_volume:
            continue
        elif curr_sugar > curr_optimal_sugar:
            continue
        elif curr_density > global_dencity:
            # print(curr_sugar, water_volume)
            global_optimal_sugar = curr_sugar
            global_optimal_water = water_volume
            global_dencity = curr_density
            
sugar_water_volume = global_optimal_water * 100 + global_optimal_sugar
print(sugar_water_volume, global_optimal_sugar)
        
        

Measured memory_bytes: 3064
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

const long mod = 998244353;
void solve(){
    int a = scan!int, b = scan!int, c = scan!int, d = scan!int;
    auto sf = new long[][](c + 1, d + 1);

    foreach(i; a .. c + 1) foreach(j; b .. d + 1){
        if(i == a && j == b) sf[i][j] = 1;
        else sf[i][j] = (sf[i][j - 1] * i + sf[i - 1][j] * j
          + mod - sf[i - 1][j - 1] * (i - 1) * (j - 1) % mod) % mod;
    }
    sf[c][d].print;
}



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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i=A; i<B+1; i++) {
		int a, b, c, d, e;
		int n = i;
		a = n%10;
		n /= 10;
		b = n%10;
		n /= 10;
		c = n%10;
		n /= 10;
		d = n%10;
		n /= 10;
		e = n%10;
		if (a==e && b==d) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll mod=1000000007, bk2[200010];
map<pair<ll, ll>, int> mp;

ll gcd(ll a, ll b){
    if(a%b) return gcd(b, a%b);
    return b;
}

int main(void){
    int N;
    cin >> N;
    ll ans=0;
    bk2[0]=1;
    for(int i=1; i<=N; ++i) bk2[i]=(bk2[i-1]*2)%mod;
    for(int i=0; i<N; ++i){
        ll A, B;
        cin >> A >> B;
        if(A==0 && B==0){
            ++ans;
        }
        else if(A==0){
            ++mp[make_pair(0, -1)];
        }
        else if(B==0){
            ++mp[make_pair(1, 0)];
        }
        else{
            ll h=gcd(abs(A), abs(B));
            if(A>0 ^ B>0){
                ++mp[make_pair(abs(A)/h, -abs(B)/h)];
            }
            else{
                ++mp[make_pair(abs(A)/h, abs(B)/h)];
            }
        }
    }
    ll mult=1;
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
        pair<ll, ll> f=itr->first;
        swap(f.first, f.second);
        if(f.first<0) f.first *= -1;
        else f.second *= -1;
        (mult *= (bk2[itr->second]+bk2[mp[f]]+mod-1)%mod) %= mod;
        itr->second=0;
        mp[f]=0;
    }
    (ans += mult+mod-1) %= mod;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    map<int, int> m;
    for (int x : a) {
        ++m[x];
    }
    if (m.size() == 1U && m.begin()->first == 0) {
        cout << "Yes\n";
        return 0;
    }
    if (m.size() > 3U || N % 3 != 0) {
        cout << "No\n";
        return 0;
    }
    vector<int> b;
    int xorb = 0;
    for (auto &p : m) {
        if (p.second % (N / 3) != 0) {
            cout << "No\n";
            return 0;
        }
        while (p.second >= N / 3) {
            p.second -= N / 3;
            b.push_back(p.first);
            xorb ^= p.first;
        }
    }
    cout << (xorb == 0 ? "Yes\n" : "No\n");


    return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean res = true;
        for(int i=0; i<n; i++) {
            int a = sc.nextInt();
            if(a % 2 == 0) {
                if(a % 5 != 0 && a % 3 != 0) {
                    res = false;
                    break;
                }
            }
        }

        System.out.println(res ? "APPROVED" : "DENIED");
    }



}


Measured memory_bytes: 25172
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A_abs = [abs(x) for x in A]

minus_cnt = len([x for x in A if x < 0])

res = 0

if minus_cnt % 2 == 0:
    res = sum(A_abs)
else:
    res = sum(A_abs) - 2*min(A_abs)

print(res)

Measured memory_bytes: 64880
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True
#for i in range(n):

ans=0

a=I()
b=I()
ans=[1,2,3]
ans.remove(a)
ans.remove(b)

print(*ans)




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

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0;i < 3;i++){
        if(s[i] == '1') cnt++;
    } 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int time_limit = 1950;
constexpr int iter_max = 2500000;
chrono::system_clock::time_point start, current;
int c[26];
int64_t s[366][26];


int64_t eval(const vector<int> &state, int d){
    int last[26] = {0};
    int64_t csum = 0;
    for(int i=0;i<26;++i) csum += c[i];
    int64_t decl = -csum;
    int64_t score = 0;

    for(int i=1;i<=d;++i){
        score += s[i][state[i]];
        decl += (i - last[state[i]])*c[state[i]];
        last[state[i]] = i;
        score += decl;
        decl -= csum;
    }
    return score;
}

struct simulated_annealing{
    random_device dev;
    mt19937_64 rng;
    uniform_real_distribution<double> dist;
    uniform_int_distribution<int> typ;
    int D;

    simulated_annealing(int d): dist{0.0, 1.0}, typ{0, 25}, D(d){
        rng.seed(dev());
    }

    vector<int> loop(){
        vector<int> state, best_state;
        state.resize(D+1); best_state.resize(D+1);
        for(int i=1;i<=D;++i) state[i] = best_state[i] = typ(rng);
        int64_t curr_score = eval(state, D), best_score = curr_score;

        for(int iter=1;;++iter){
            current = chrono::system_clock::now();
            if(chrono::duration_cast<chrono::milliseconds>(current-start).count() >= time_limit) break;
            auto next_state = neighbor(state);
            int64_t next_score = eval(next_state, D);

            if(next_score >= curr_score || dist(rng) <= probability(curr_score, next_score, temperature(iter))){
                curr_score = next_score;
                state = next_state;
                if(best_score < curr_score){
                    best_score = curr_score;
                    best_state = state;
                }
            }
        }
        return best_state;
    }
    vector<int> neighbor(const vector<int> &curr){
        vector<int> ret{curr};
        int x = rand() % D + 1;
        ret[x] = typ(rng);
        return ret;
    }
    double probability(double score1, double score2, double t){
        if(score1 <= score2) return 1.0;
        else return exp((score2 - score1) / t);
    }
    double temperature(int step){
        double x = step * 1.0 / iter_max;
        return (1.0 - tanh(x)) * 1e4;
    }
};

int main(){
    start = chrono::system_clock::now();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);

    int d;
    cin >> d;
    for(int i=0;i<26;++i) cin >>c[i];
    for(int i=1;i<=d;++i){
        for(int j=0;j<26;++j) cin >> s[i][j];
    }
    simulated_annealing sa(d);
    auto ans = sa.loop();

    for(int i=1;i<=d;++i) cout << ans[i] + 1 << endl;

    return 0;
}

Measured memory_bytes: 4348
def resolve():
    X = int(input())
    if X <= 99:
        print('0')
        return

    for i in range(1, 1000 + 1):
        if 100 * i + 6 + (i - 1) * 5 <= X <= 100 * i + 99:
            print('0')
            return
    print('1')

    return

resolve()

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int A,B; cin>>A>>B;
  int C=__gcd(A,B);
  set<int> S;
  for(int i=2;i*i<=C;i++){
    while(C%i==0){
      C/=i;
      S.insert(i);
    }
  }
  if(C>1) S.insert(C);
  cout<<S.size()+1<<endl;
  }



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

const int kMaxJumpStep = 3;

int dp(const int N){
	std::vector<int> step(N+1);
	step[0] = 1;

	for (int i = 0; i <= N; i++){
		for (int j = i + 1; j <= i + kMaxJumpStep; j++){
			if (j > N) break;
			step[j] += step[i];
		}
	}

	return step[N];
}

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

	while (1){
		int n;
		std::cin >> n;
		if (n == 0) break;
		std::cout << dp(n)/3650 + 1 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
const ll inv2=(MOD+1)/2;
int n;
vector<int> g[200020];
int cnt[200020];
ll p2[200020], p2inv;
ll ans;
void dfs(int x, int p){
	cnt[x]=1;
	ll s=1;
	for(auto y:g[x]){
		if(y==p) continue;
		dfs(y, x);
		cnt[x]+=cnt[y];
		s+=p2[cnt[y]]-1;
	}
	s+=p2[n-cnt[x]]-1;
	s%=MOD;
	s=(1-p2inv*s%MOD+MOD)%MOD;
	(ans+=s*inv2)%=MOD;
}
int main()
{
	cin>>n;
	for(int i=0; i<n-1; i++){
		int a, b; cin>>a>>b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	p2[0]=1;
	for(int i=1; i<=n; i++) p2[i]=p2[i-1]*2%MOD;
	p2inv=inv(p2[n-1]);
	dfs(0, -1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 24704
N, Y = map(int, input().split())
Y2 = Y // 1000
mod5 = Y2 % 5
div5 = Y2 // 5
for c_div5 in range(div5 + 1):
    c = c_div5 * 5 + mod5
    a = (Y2 - c) // 5 - (N - c)
    b = N - a - c
    if a >= 0 and b >= 0: break
    if c_div5 == div5: a=-1;b=-1;c=-1
print(a, b, c)

Measured memory_bytes: 3064
def main():
    n = map(int, list(input()))
    a = list(map(int, input().split()))
    height = 0
    max_height = a[0]
    for _a in a[1:]:
        if _a == max_height:
            continue
        elif _a > max_height:
            max_height = _a
        else:
            height += max_height - _a
    print(height)



if __name__ == "__main__":
    main()


Measured memory_bytes: 32240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int lcm(string s, string t, vector<vector<int>> dp){
    int m = s.size();
    int n = t.size();
    int maxl = 0;
    s = " " + s;
    t = " " + t;
    for(int i=0; i<=m; i++) dp[i][0] = 0;
    for(int j=0; j<=n; j++) dp[0][j] = 0;

    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
            if(s[i] == t[j]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            maxl = max(maxl, dp[i][j]);
        }
    }

    return maxl;
}

int main(){
    vector<vector<int>> dp(1001, vector<int>(1001, 0));

    int n; cin >> n;
    for(int i=0; i<n; i++){
        string s, t; cin >> s >> t;
        cout << lcm(s, t, dp) << endl;
    }
}


Measured memory_bytes: 10780
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
void solve_dubling() {
    // 10^5回後の移動先がわかれば良い
    // 偶数回移動でループするので
    // 10^100 = 10^5となる
    // Doublingで移動先を求める
    string S;
    cin >> S;

    int n = S.size();
    int MAXD = log2(1e+5 + 5);
    vector<vector<int>> to(MAXD + 1, vector<int>(n));
    // init
    // S[i] = R -> i + 1へ移動
    // S[i] = L -> i - 1へ移動
    for (int i = 0; i < n; i++) {
        if (S[i] == 'R') to[0][i] = i + 1;
        else to[0][i] = i - 1;
    }

    for (int d = 0; d < MAXD; d++) {
        for (int i = 0; i < n; i++) {
            to[d + 1][i] = to[d][to[d][i]];
        }
    }

    int k = 1e+5;
    vector<int> cnt(n);
    for (int i = 0; i < n; i++) {
        int x = i;
        for (int d = MAXD; d >= 0; d--) {
            int b = 1 << d;
            if (k & b) x = to[d][x];
        }
        cnt[x]++;
    }

    for (int i = 0; i < n; i++) {
        if (i) cout << ' ';
        cout << cnt[i];
    }
    cout << '\n';
}
/* main */
int main(){
    solve_dubling();
}


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

int xa,ya,xb,yb,xc,yc,xd,yd;

int main(){
  cin >> xa>>ya>>xb>>yb;
  xc=ya-yb+xb;
  yc=yb-xa+xb;
  xd=xa-xb+xc;
  yd=yc-yb+ya;
  cout << xc <<" "<< yc<<" " << xd <<" "<< yd << endl;
}


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

int main() {
    int n,a[51],x=1e9,y=-1e9;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        x=min(x, a[i]);
        y=max(y, a[i]);
    }
    if(x<0&&y>0){
        int z=y,w=0;
        if(-x>y){
            z=x;
            y+=x;
        }else{
            x+=y;
        }
        for(int i=0;i<n;i++){
            if(a[i]==z){
                w=i+1;
            }
        }
        cout<<n*2-1<<endl;
        for(int i=1;i<=n;i++){
            if(i!=w){
                cout<<w<<" "<<i<<endl;
            }
        }
        cout<<w<<" "<<w<<endl;
    }else{
        cout<<n-1<<endl;
    }
    if(x>=0){
        for(int i=1;i<n;i++){
            cout<<i<<" "<<i+1<<endl;
        }
        return 0;
    }
    if(y<=0){
        for(int i=n;i>1;i--){
            cout<<i<<" "<<i-1<<endl;
        }
        return 0;
    }
    
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int a[52];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	double sum=a[0];
	for(int i=1;i<n;i++)
	{
		sum=(sum+a[i])/2;
	}
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		Number number[] = new Number [N];
		Main main = new Main();
		for (int i=0;i<N;i++) {
			Number num = main.new Number();
			num.a=sc.nextInt();
			num.b= sc.nextInt();
			number[i] =num;
		}
		Arrays.sort(number);
		long count =0;
		for (int i=0;i<N;i++) {
			count+=number[i].b;
			if (count>=K) {
				System.out.println(number[i].a);
				return;
			}
		}
	}
	public class Number implements Comparable<Number> {

		int a ;
		int b;
		@Override
		public int compareTo(Number o) {
			return this.a-o.a;
		}

	}
}

Measured memory_bytes: 82232
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

using namespace std;

typedef pair<int,int> pii;

int m[4010][4010],w,h;

int main(){
	int n,ans,a[2003],b[2003],cnt;
	for(;;){
		scanf("%d%d",&w,&h);
		if(w == 0 && h == 0)break;
		scanf("%d",&n);
		ans = 0;
		vector<pii> x,y,rx,ry;
		n*=2;
		rep(i,n){
			scanf("%d%d",a+i,b+i);
			x.push_back(pii(a[i],i));
			y.push_back(pii(b[i],i));
		}
		x.push_back(pii(0,n));
		y.push_back(pii(0,n));
		x.push_back(pii(w,n+1));
		y.push_back(pii(h,n+1));
		sort(x.begin(),x.end());
		sort(y.begin(),y.end());
		cnt=0;
		for(int i=0;i<n+2;cnt+=2){
			for(int t=x[i].first;x[i].first==t;i++){
				a[x[i].second]=cnt;
				w=cnt;
			}
		}
		cnt=0;
		for(int i=0;i<n+2;cnt+=2){
			for(int t=y[i].first;y[i].first==t;i++){
				b[y[i].second]=cnt;
				h=cnt;
			}
		}
		rep(i,4010)rep(j,4010)m[i][j]=0;
		for(int i=0;i<n;i+=2){
			reps(j,a[i],a[i+1])reps(k,b[i],b[i+1]){
				m[j][k]=-1;
			}
		}
		//rep(i,h){rep(j,w)printf("%2d",m[j][i]);puts("");}
		queue<pii> q;
		int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
		rep(i,w)rep(j,h){
			if(m[i][j]==0){
				q.push(pii(i,j));
				m[i][j]=++ans;
				while(!q.empty()){
					pii t = q.front();
					q.pop();
					int tx=t.first,ty=t.second;
					rep(j,4)
						if(tx+dx[j]>=0 && tx+dx[j]<=w && ty+dy[j]>=0 && ty+dy[j]<=h)
							if(m[tx+dx[j]][ty+dy[j]]==0){
								m[tx+dx[j]][ty+dy[j]]=ans;
								q.push(pii(tx+dx[j],ty+dy[j]));
							}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 63900
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII; 
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-9;
const double PI = acos(-1);
const LL INFF = 1e18;
const int INF = 1e9+1;
const int mod = 1e9+7;
const int MAX = 1e5+7;
int n;
LL ans = 0;
string s, a, b;
map<pair<string, string>, LL>mp;
void go(int p, string s1, string s2){
  if(p == n){
    mp[MP(s1, s2)]++;
    return ;
  }
  go(p+1, s1 + a[p], s2);
  go(p+1, s1, s2 + a[p]);
  return ;
}
void gogo(int p, string s1, string s2){
  if(p == n){
    ans += mp[MP(s1, s2)];
    return ;
  }
  gogo(p+1, s1 + b[p], s2);
  gogo(p+1, s1, s2 + b[p]);
  return ;
}
int main(void){
  cin >> n >> s;
  a = s.substr(0, n);
  b = s.substr(n, n); reverse(ALL(b));
  go(0, "", "");
  gogo(0, "", "");
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 87808
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Feb  9 21:12:57 2019
//
package main

import "fmt"

func search(graph [][]bool, visited []bool) {
	q := []int{0}

	for len(q) > 0 {
		n := q[0]
		q = q[1:]

		visited[n] = true
		for i := range graph[n] {
			if graph[n][i] {
				graph[n][i] = false
				graph[i][n] = false
				q = append(q, i)
				break
			}
		}
	}
}

func main() {
	graph := make([][]bool, 4)
	for i := range graph {
		graph[i] = make([]bool, 4)
	}

	for i := 0; i < 3; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		graph[a-1][b-1] = true
		graph[b-1][a-1] = true
	}

	visited := make([]bool, 4)
	search(graph, visited)
	if visited[0] && visited[1] && visited[2] && visited[3] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 10005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    cout << "ABC";
    string s;
    cin >> s;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100000

int linerSearch(int[],int[],int,int);

int main(){
    
    int i,n,q;
    
    scanf("%d",&n);
    
   if(n<=N){
        
        int s[N];
        
        for(i=0 ; i<n ; i++){
            scanf("%d",&s[i]);
        }

        scanf("%d",&q);
        
       if(q<=N){
            
            int t[N];
            
            for(i=0 ; i<q ; i++){
                scanf("%d",&t[i]);
            }
            
            printf("%d\n",linerSearch(s,t,n,q));

        }
    }
    return 0;
}


int  linerSearch(int s[N],int t[N],int n,int q){
    int i,j=0,count=0,key;
    for(i=0 ; i<q ; i++){
        j = 0;
        key = t[i];
        while(s[j] != key){
           j++;
           if(j==n)break;
        }
        if(j!=n)count++;
    }
    return count;
}



Measured memory_bytes: 2144
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

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

class Dfs(private val n: Long) {
    private fun is753(k: Long): Boolean = k.toString().let {
        (it.contains('7') && it.contains('5') && it.contains('3'))
    }
    fun dfs(k: Long): Long = when {
        k > n -> 0L
        else -> dfs(k * 10L + 7L) + dfs(k * 10L + 5L) + dfs(k * 10L + 3L) + if(is753(k)) 1L else 0L
    }
}

fun main(args: Array<String>) {
    val n = readLong()

    println(Dfs(n).dfs(0L))
    
    pw.flush()
}

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

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

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

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

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

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

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

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

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

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

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


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

int main(){
  int N,K;
  cin >> N >> K;
  int p[N]={0};
  for (int i=0; i<N; i++){
    cin >> p[i];
  }
  sort(p,p+N);
  int somme=0;
  for (int j=0; j<K; j++){
    somme+=p[j];
  }
  cout << somme;
}


Measured memory_bytes: 3608