akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int main(void)
{
    ll n, k;
    cin >> n >> k;
    vll a(n);
    rep(i, 0, n) cin >> a[i];

    ll l, m = 0;
    rep(i, 0, n)
    {
        l = (i == 0) ? a[i] : gcd(a[i], l);
        m = max(m, a[i]);
    }
    cout << ((k % l == 0 && k <= m) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

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

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
  cin >> n;
  int  ans = ceil((double)n / 1.08);
  int a = ans * 1.08;
  if(a == n) {
    cout << ans << endl;
  }else {
  	cout << ":(" << endl;
  }

}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      if (a * b % 2 == 0)
        System.out.println("Even");
      else
        System.out.println("Odd");
    }
}


Measured memory_bytes: 21716
A1 = list(map(int, input().split()))
A2= list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = A1 + A2 + A3

N = int(input())

B = []
for i in range(N):
    B.append(int(input()))

# 縦のビンゴがある
def isExistTatePair():
    # すべての当選番号を調べる
    for i in range(3):
            sum = 0
            for j in range(3):
                sum += A[3 * j + i]
            
            # ビンゴか調べる
            if sum == 0:
                return True
    return False
    
# 横のビンゴがある
def isExistYokoPair():
    # すべての当選番号を調べる
    for i in range(3):
            sum = 0
            for j in range(3):
                sum += A[3 * i + j]
            
            # ビンゴか調べる
            if sum == 0:
                return True
    return False
    
# ななめのビンゴがある
def isExistNanamePair():
    # 左上から右下へのななめ
    naname1 = A[0] + A[4] + A[8]
    
    if naname1 == 0:
        return True
    
    # 右上から左下へのななめ
    naname2 = A[2] + A[4] + A[6]
    
    if naname2 == 0:
        return True
    
    return False

# 当選番号を見てビンゴカードに穴をあける
for b in B:
    for index in range(len(A)):
        a = A[index]
        if a == b:
            A[index] = 0
    
isExistBingo = isExistTatePair() or isExistYokoPair() or isExistNanamePair()
print('Yes' if isExistBingo else 'No')

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int n = s.length;
			Set<Character> set = new HashSet<>();
			for (int i = 0; i < n; i++) {
				set.add(s[i]);
			}

			if (n < 26) {
				for (char c = 'a'; c <= 'z'; c++) {
					if (!set.contains(c)) {
						out.println(new String(s) + c);
						return;
					}
				}
			} else if ((new String(s)).equals("zyxwvutsrqponmlkjihgfedcba")) {
				out.println(-1);
				return;
			} else {
				int[] c = new int[s.length];
				for (int i = 0; i < c.length; i++) c[i] = s[i] - 'a';
				Permutation.next(c);
				for (int i = 0; i < c.length; i++) {
					if ((c[i] + 'a') == s[i]) {
						out.print((char)(c[i] + 'a'));
					} else {
						out.println((char)(c[i] + 'a'));
						return;
					}
				}
			}

		}
	}
	static class Permutation {
		public static boolean next(int[] a) {
			int n = a.length;

			int i = n - 1;
			while (i > 0 && a[i - 1] >= a[i])
				i--;
			if (i <= 0)
				return false;

			int j = n - 1;
			while (a[j] <= a[i - 1])
				j--;
			swap(a, i - 1, j);

			int k = n - 1;
			while (i < k)
				swap(a, i++, k--);

			return true;
		}

		private static void swap(int[] a, int i, int j) {
			int tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}
}


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

int main()
{
  int n;
  cin>>n;
  
  int arr[n+1];
  
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i];
  }
  
  int k=0;
  
  for(int i=1;i<=n;i++)
  {
    if(i%2!=0 && arr[i]%2!=0)
      k++;
  }
  
  cout<<k<<endl;
  
  return 0;}

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

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
		int N = Integer.parseInt(sc.next());
		int L = Integer.parseInt(sc.next());
		String[] sss = new String[N];
		
		for (int i = 0; i < N; i ++) {
			sss[i] = sc.next();
		}
		StringBuilder sb = new StringBuilder();
		Arrays.stream(sss).sorted().forEach(sb::append);
		
		System.out.println(sb.toString()); 
	} // Scanner Close

	}
}

Measured memory_bytes: 27220
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

ll n, k;

int main(){

    cin >> n >> k;

    ll d = __gcd(n, k);

    cout << 3ll * (n - d) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define piv(a,v) pair<int,vector<int> >(a,v)

int main(void){
	int n, m;
	cin >> n >> m;
	vector<int> v[n]; // 1→0
	rep(i, m){
		int ts, tt;
		cin >> ts >> tt;
		v[ts-1].push_back(tt-1);
		v[tt-1].push_back(ts-1);
	}
	
	int ans = 0;
	
	queue < pair< int, vector<int> > > q;
	vector<int> tv; tv.push_back(0);
	q.push(piv(0, tv));
	
	while(true){
		pair< int, vector<int> > t = q.front(); q.pop();
		if(t.sec.size() == n) ans++;
		else{
			rep(i, v[t.fir].size()){
				if(find(t.sec.begin(), t.sec.end(), v[t.fir][i]) == t.sec.end()){
					pair< int, vector<int> > s = t;
					s.fir = v[t.fir][i];
					s.sec.push_back(s.fir);
					q.push(s);
				}
			}
		}
		
		if(q.size()==0) break;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

bool dp[1 << 24];
int can[1 << 24];
int cover[30];
int x[30], y[30], r[30], c[30];

int main() {
    int N;
    while(1) {
        scanf("%d", &N);
        if(!N) break;
        memset(dp, false, sizeof(dp));
        memset(can, 0, sizeof(can));
        memset(cover, 0, sizeof(cover));

        vector< vector<int> > colors(4);
        for(int i=0; i<N; i++) {
            scanf("%d%d%d%d", &x[i], &y[i], &r[i], &c[i]);
            c[i]--;
            colors[ c[i] ].push_back(i);
        }

        // i が j によって覆われる
        for(int i=0; i<N; i++) {
            for(int j=0; j<i; j++) {
                int diff_x = x[i] - x[j];
                int diff_y = y[i] - y[j];
                int A = diff_x * diff_x + diff_y * diff_y;
                int B = (r[i] + r[j]) * (r[i] + r[j]);
                if(A < B) {
                    cover[i] |= (1 << j);
                }
            }
        }

        dp[(1<<N)-1] = true;
        for(int bit=(1<<N)-1; bit>=0; bit--) {
            if(!dp[bit]) continue;
            for(int k=0; k<4; k++) {
                int S = colors[k].size();
                if(S < 2) continue;

                for(int i=0; i<S; i++) {
                    for(int j=i+1; j<S; j++) {
                        int u = colors[k][i], v = colors[k][j];
                        if(bit & cover[u]) continue;
                        if(bit & cover[v]) continue;
                        if((bit >> u & 1) == 0) continue;
                        if((bit >> v & 1) == 0) continue;

                        int nbit = bit ^ (1 << u) ^ (1 << v);
                        dp[nbit] = true;
                    }
                }
            }
        }

        int ans = 0;
        for(int bit=0; bit<(1<<N); bit++) {
            if(dp[bit]) ans = max(ans, N - __builtin_popcount(bit));
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 84732
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

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

typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  int ans = 0;
  rep(i, x) {
      rep(j, x) {
          if (i%j == 0 && 
             (j*j == i || j*j*j == i || j*j*j*j*j == i)) ans = i;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};


int main() {
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h)cin >> s[i];
  auto chk = [&](int x,int y){
    int cnt=0;
    rep(k,4){
      int xx = x+dx[k];
      int yy = y+dy[k];
      if(xx<0 || xx>=h||yy<0||yy>=w)continue;
      if(s[xx][yy] == '#')cnt++;
    }
    if(cnt>=1)return true;
    //cout<<x <<" "<<y<<endl;
    return false;
  };
  bool ok = true;
  rep(i,h)rep(j,w){
    if(s[i][j] == '#')
    ok&=chk(i,j);
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC70(void);
void ABC71(void);
void ABC72(void);
void ABC73(void);
void ABC75(void);
void ABC77(void);
void ABC78(void);
void ABC79(void);

int main(void){
    ABC77();
}

void ABC77(void){
    char a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    if(a==f&&b==e&&c==d)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

int main()
{
	string s;
	cin>>s;
	int sum=0;
	int i=0;
	for(i=0;i<s.length();i++)
	{
		sum+=s[i]-'0';
	}
	if(sum%9==0)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}

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

int memo[2020];
const int modnum = 2019;

int main(){
	string s;

	cin >> s;
	reverse(s.begin(), s.end());

	for(int i=0; i<2020; i++){
		memo[i] = 0;
	}
	memo[0] = 1;

	int sum = 0;
	int moddig = 1;
	for(int i=0; i<s.size(); i++){
		sum +=  ((int)(s[i]-'0') * moddig) % modnum;
		sum %= modnum;
		memo[sum]++;
		moddig = moddig * 10 % modnum;
	}

	ll ans = 0;
	for(int i=0; i<2020; i++){
		if(memo[i] <= 0){
			continue;
		}

		ans += memo[i] * (memo[i] - 1) / 2;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3728
package main

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

func main() {
	n := readInt()

	a := make([]int, n)
	c := make([]int, n-1)

	ans := 0
	for i := range a {
		a[i] = readInt()
	}
	for range a {
		ans += readInt()
	}
	for i := range c {
		c[i] = readInt()
	}

	pre := -1
	for i := range a {
		if a[i] == pre+1 {
			ans += c[pre-1]
		}
		pre = a[i]
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


vector<int> v[100000];
vector<bool> u(100000,false);

int main(){
  ll A, B, C,D, E,F,G;
  cin >> A >> B >> C >> D;
  if(C > D){
    E = C;
    F = D;
  }
  else{
    E = D;
    F = C;
  }
  G = E % F;
  while(G != 0){
    E = F;
    F = G;
    G = E % F;
  }
  cout << B-A+1-(B / C - (A-1)/C)-(B / D - (A-1)/D)+(B/(C/F*D) - (A-1)/(C/F*D)) << endl;
  return 0;
}

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

namespace abc073_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInt();
            var AD = new Dictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                var a = GetInt();
                if (!AD.ContainsKey(a)) AD.Add(a, 0);
                AD[a]++;
            }

            Console.WriteLine(AD.Values.Where(x => x % 2 == 1).Count());
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();


    }
}


Measured memory_bytes: 18396
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<long long,long long>
#define ppii pair<long long,pair<long long,long long>>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<vector<long long>> vii;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;
const int MAX_N = 1 << 17;
const int cf = 100010;
///////////////////////////////////////////////////////////////////////////////

int main() {
	vector<tuple<lint, lint, lint>> G;
	lint L; cin >> L;
	lint r = log2(L);
	debug(r);
	for (int i = 0; i < r; i++)
	{
		G.pb(tuple<lint, lint, lint>(i + 1, i + 2, 0));
		G.pb(tuple<lint, lint, lint>(i + 1, i + 2, qp(2,i)));
	}
	for (lint i = r ; i >= 1; i--)
	{
		
		if (L - qp(2, i-1) >= qp(2, r) ){
			G.pb(tuple<lint,lint,lint>(i,r+1, L - qp(2, i-1)));
			L -= qp(2, i - 1);
		}
		
	}

	cout << r + 1 << " " << G.size() << endl;
	for (int i = 0; i < G.size(); i++) {
		lint a = get<0>(G[i]), b = get<1>(G[i]), c = get<2>(G[i]);
		cout << a << " " << b << " " << c << endl;
	}
	return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int n;
vector<vi> adj;

int go(int u, int p) {
    int ans = 0;
    for (int v : adj[u]) if (v != p) {
        ans ^= 1 + go(v,u);
    }
    return ans;
}

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


    cin >> n;
    adj.resize(n);
    forn(_,n-1) {
        int u,v; cin >> u >> v;
        u--; v--;
        adj[u].pb(v); adj[v].pb(u);
    }

    int ans = go(0,-1);
    cout << (ans ? "Alice" : "Bob") << endl;

    return 0;
}


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

int main() {
    int n ;
    cin >> n;
    int a[n+1];
    a[0] = 1;
    a[1] = 1;
    for (int i = 2; i <= n; i++) {
        a[i] = a[i-1] + a[i-2];
    }
    
    cout << a[n] << endl;
    
    return 0;
    
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}
const int maxn = 2e5 + 7;
vi par(maxn, -1);
int root(int v) {
	return par[v] < 0 ? v : (par[v] = root(par[v]));
}
bool merge(int x, int y) {
	if ((x = root(x)) == (y = root(y)))
		return false;
	if (par[y] < par[x])	// balancing the height of the tree
		swap(x, y);
	par[x] += par[y];
	par[y] = x;
	return true;
}
vi par2(maxn, -1);
int root2(int v) {
	return par2[v] < 0 ? v : (par2[v] = root2(par2[v]));
}
bool merge2(int x, int y) {
	if ((x = root2(x)) == (y = root2(y)))
		return false;
	if (par2[y] < par2[x])	// balancing the height of the tree
		swap(x, y);
	par2[x] += par2[y];
	par2[y] = x;
	return true;
}
void solve() {
	int n, k, l;
	cin >> n >> k >> l;
	vi a(maxn, 1);
	rep(i, 0, k) {
		int p, q;
		cin >> p >> q;
		merge(p, q);
	}
	rep(i, 0, l) {
		int p, q;
		cin >> p >> q;
		merge2(p, q);
	}
	map<pi, int> m;
	rep(i, 1, n + 1) {
		m[ {root(i), root2(i)}]++;
	}
	rep(i, 1, n + 1)cout << m[ {root(i), root2(i)}] << " ";
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 16824
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  string x;
  cin>>x;
  int l=x.length(),m=0,s=0;
  rep(i,l){
    if(x[i]=='T'){
      s++;
    }else{
      s--;
    }
    m=max(m,s);
  }
  cout<<2*m;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;

int N, M;
ll A;
vector<pair<int, ll > > BC;
vector<ll> V;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}

int main(void){
    // Your code here!
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        cin >> A;
        V.push_back(A);
    }
    
    
    int tmp1;
    ll tmp2;
    for(int i = 0; i < M; i++) {
        cin >> tmp1 >> tmp2;
        BC.push_back(make_pair(tmp1, tmp2));
    }
    sort(BC.begin(),BC.end(), pairCompare);

    int cnt = 0;
    int idx = 0;
    while(true){
        if(cnt == N) break;
        if(idx == M) break;
        
        if(cnt + BC[idx].first <= N) {
            for(int j = 0; j <  BC[idx].first; j++) V.push_back(BC[idx].second);
            cnt += BC[idx].first;
        } else{
            int left = N - cnt;
            for(int j = 0; j < left; j++) V.push_back(BC[idx].second);
            cnt += left;
        }
        idx++;
        
    }
    
    
    sort(V.begin(),V.end(),greater<ll>());
    ll ans =0 ;
    for(int i = 0; i < N; i++) ans += V[i];
    cout << ans << endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

const int MAX = 7368791;

int solve(int m, int n) {
    vector<bool> vec(MAX + 1, true);
    vec[0] = vec[1] = false;
    int cnt = 0;

    for (int i = m; i < MAX + 1; i++) {
        if (!vec[i]) continue;
        cnt += 1;

        if (cnt == n + 1) {
            return i;
        }

        for (int j = i * 2; j < MAX + 1; j += i) {
            vec[j] = false;
        }
    }
}

int main() {
    int m, n;

    while (cin >> m >> n && m) {
        cout << solve(m, n) << endl;
    }
}


Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="0"){
      break;
    }
    int sum=0;
    for(int i=0;i<(int)str.size();i++){
      sum+=str[i]-'0';
    }
    cout<<sum<<endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

bool isACGT(char s) {
  return (s == 'A' || s == 'G' || s == 'C' || s == 'T');
}

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

  string str;
  cin >> str;

  int ans = 0;
  for (int i = 0; i < str.length(); i++) {
    char current = str[i];
    if (!isACGT(current)) {
      continue;
    }

    int count = 1;
    for (int j = i + 1; j < str.length(); j++) {
      char next = str[j];
      if (!isACGT(next)) {
        break;
      }
      count++;
    }

    ans = max(ans, count);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 10011
long long d[INF];
long long m[INF];
int dis[INF][INF];
int n;
int a[INF], b[INF];
int c[INF];
vector<int> vec;
void bfs(int s)
{
    int i = 0;
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; i++)
    {
        d[i] = INF * INF;
        m[i] = INF * INF;
    }
    m[s] = 0;
    d[s] = vec[i];
    int u;
    while (!q.empty())
    {
        u = q.front();
        q.pop();
        for (int v = 0; v < n; v++)
        {
            if (dis[u][v] == 0)
                continue;
            if (m[v] != INF * INF)
                continue;
            i++;
            d[v] = vec[i];
            m[v] = m[u] + 1;
            q.push(v);
        }
    }
}
int main()
{
    cin >> n;
    map<int, int, greater<int>> mp;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            dis[i][j] = 0;
        }
    }
    int ma = -1;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        mp[a[i]]++;
        mp[b[i]]++;
        dis[a[i]][b[i]] = 1;
        dis[b[i]][a[i]] = 1;
    }
    int x;
    for (auto p : mp)
    {
        x = p.first;
        break;
    }

    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        vec.push_back(c[i]);
    }
    sort(vec.rbegin(), vec.rend());
    bfs(x);
    long long sum = 0;
    for (int i = 0; i < n - 1; i++)
    {
        dis[a[i]][b[i]] = min(d[a[i]], d[b[i]]);
        sum += dis[a[i]][b[i]];
    }
    cout << sum << endl;
    for (int i = 0; i < n; i++)
    {
        cout << d[i] << " ";
    }
}


Measured memory_bytes: 392192
h,w,k = map(int,input().split())
mod = 10**9+7

dp = [[0 for i in range(w)] for j in range(h+1)]

dp[0][0] = 1
for i in range(1,h+1): #高さ
    for p in range(2**(w-1)):
        bit = list(str(bin(p)))
        bit.pop(0)
        bit.pop(0)
        for a in range(w-1-len(bit)):
            bit.insert(0,"0")
        temp = True
        for a in range(w-2):
            if bit[a] == "1" and bit[a] == bit[a+1]:
                temp = False
        if temp:
            mix = [b for b in range(w)]
            for a in range(w-1):
                if bit[a] == "1":
                    mix[a],mix[a+1] = mix[a+1],mix[a]
            for b in range(w):
                dp[i][b] += dp[i-1][mix[b]]
                dp[i][b] = dp[i][b]%mod
print(dp[h][k-1])


Measured memory_bytes: 3188
// https://atcoder.jp/contests/abc129/tasks/abc129_c

#include <stdio.h>
#define FOR(i,L,R) for (int i = L; i < R; i++)
#define MOD 1000000007
#define wez(n) int (n); scanf("%d",&(n))

int main(){
    wez(n);
    wez(m);
    int arr[100000];
    // initiate every step to value -1
    for (int i = 0; i <= n; i++)
        arr[i] = -1;
    
    // if the step is broke, change every value to 0
    FOR(i, 0, m){
        wez(a);
        arr[a] = 0;
    }
    
    // set the foot of the stairs equal to 1, and if the first step isn't broken, set it equal to 1
    arr[0] = 1;
    if (arr[1] == -1)
        arr[1] = 1;
    
    /* basically, we go to every step that isn't broken. to find the amount of different ways to get to that step,
       you just add the number of different ways to get to the last two steps. */
    for (int i = 0; i <= n; i++){
        if (arr[i] == -1)
            arr[i] = (arr[i - 1] + arr[i - 2]) % MOD;
    }
    
    printf("%d\n", arr[n]);
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
using namespace std;
#define Rep(i,n) for(int i = 0; i < n; ++i)
#define For(i, s, e) for(int i = s; i <= e; ++i)
string s;
int K;
string M[30000];
int main()
{
	ios::sync_with_stdio(false);
	cin >> s >> K;
	int n = s.size();
	Rep(i, K) {
		Rep(j, n)
			M[5000 * i + j] = s.substr(j, i + 1);
	}
	sort(M, M + 25001);
	unique(M, M + 25001);
	cout << M[K] << endl;
	return 0;
}

Measured memory_bytes: 1664
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
l = i()
print((l/3)**3)

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

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int s[m], c[m];
    rep(i, m)
    {
        scanf("%d%d", &s[i], &c[i]);
    }
    int ans = 0;
    bool set;
    bool end = false;
    int cur;
    rep(i, n)
    {
        set = false;
        rep(j, m)
        {
            if (i + 1 == s[j])
            {
                if (set && (c[j] != cur) || i == 0 && c[j] == 0 && n > 1)
                {
                    end = true;
                }
                set = true;
                cur = c[j];
            }
        }
        if (set)
        {
            ans += cur * pow(10, n - i - 1);
        }
    }
    if (n > 1 && ans < pow(10, n - 1))
    {
        ans += pow(10, n - 1);
    }

    if (end)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 256
n = gets.to_i
arr = gets.chomp.split.map(&:to_i)
puts arr.join(" ")

1.upto(n -1){ |i|
  cur = arr[i]
  j = i-1
  while j >= 0 && cur < arr[j]
    arr[j+1] = arr[j]
    j -= 1
  end
  arr[j+1] = cur
  puts arr.join(" ")
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  vector<ll> ans;
  ll tmp = 0;
  REP(i, N) { // i = 0
    if(i % 2 == 0) tmp += A[i];
    else tmp -= A[i];
  }
  ans.push_back(tmp);
  tmp = 0;
  REP(i, N) { // i = 1
    if(i % 2 == 1 || i == 0) tmp += A[i];
    else tmp -= A[i];
  }
  ans.push_back(tmp);
  tmp = 0;
  for(int i = 2; i < N; ++i) { // i = 2以降はO(1)で求める
    tmp = ans[i - 2] + (A[i - 1] * 2 - A[i - 2] * 2);
    ans.push_back(tmp);
  }
  REP(i, N) {
    cout << ans[i];
    if(i != N - 1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 5056
//Sha3ban_El-Bay
#include<bits/stdc++.h>
using namespace std ;
//======================================================
#define El_Bay ios_base::sync_with_stdio(false);cin.tie(NULL);
#define forn(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for1(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define all(v)     (v).begin(),(v).end()
#define ull        unsigned long long
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define S          second
#define bgn        begin
#define F          first
#define N          1000000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;}
//======================================================
int a[N][4],dp[N][4];
int solve(int i, int f, int n)
{
	if(i==n) return 0;

	if(dp[i][f]!=-1) return dp[i][f];

	int mx=INT_MIN;
	if(f==0)
	{
		mx=max( mx , a[i][1] + solve(i+1,1,n) );
		mx=max( mx , a[i][2] + solve(i+1,2,n) );
		mx=max( mx , a[i][3] + solve(i+1,3,n) );
	}
	if(f==1)
	{
		mx=max( mx , a[i][2] + solve(i+1,2,n) );
		mx=max( mx , a[i][3] + solve(i+1,3,n) );
	}
	if(f==2)
	{
		mx=max( mx , a[i][1] + solve(i+1,1,n) );
		mx=max( mx , a[i][3] + solve(i+1,3,n) );
	}
	if(f==3)
	{
		mx=max( mx , a[i][1] + solve(i+1,1,n) );
		mx=max( mx , a[i][2] + solve(i+1,2,n) );
	}
	dp[i][f]=mx;
	return mx;
}
int main()
{
	El_Bay
	int n;
	cin >> n ;
	for(int i=0 ; i<n ; i++)
		for(int j=1 ; j<=3 ; j++)
			cin >> a[i][j];

	memset(dp,-1,sizeof dp);
	cout << solve(0,0,n);
	return 0;
}


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

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

    vector<int> a(N);
    rep(i, N) {
        cin >> a.at(i);
    }

    rep(i, N - 1) {
        rep (j, N - 1 - i) {
            if (a.at(j) < a.at(j + 1)) {
                int tmp = a.at(j);
                a.at(j) = a.at(j + 1);
                a.at(j + 1) = tmp;
            }
        }
    }

    int ans = 0;
    rep(i, N) {
        if (i % 2 == 0) {
            ans += a.at(i);
        } else {
            ans -= a.at(i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct point{
    double x=0,y=0;
    constexpr point(double x=0,double y=0):x(x),y(y){}
    constexpr bool operator==(const point& r)const{return (x==r.x&&y==r.y);};
    constexpr point operator+(const point& r)const{return point(*this)+=r;}
    constexpr point operator+=(const point& r){
        x+=r.x;y+=r.y;
        return *this;
    }
    constexpr point operator-(const point& r)const{return point(*this)-=r;}
    constexpr point operator-=(const point& r){
        x-=r.x;y-=r.y;
        return *this;
    }
    constexpr point operator*(const double& r)const{return point(*this)*=r;}
    constexpr point operator*=(const double& r){
        x*=r;y*=r;
        return *this;
    }
    constexpr point operator/(const double& r)const{return point(*this)/=r;}
    constexpr point operator/=(const double& r){
        x/=r;y/=r;
        return *this;
    }
};

double norm(const point& a){return a.x*a.x+a.y*a.y;}
double abs(const point& a){return sqrt(a.x*a.x+a.y*a.y);}
double dot_product(const point& a,const point& b){return a.x*b.x+a.y*b.y;}
double cross_product(const point& a,const point& b){return a.x*b.y-a.y*b.x;}
point projection(const point& p,const point& b){return b*dot_product(p,b)/norm(b);}

point Point[110];

int main(){
    int n = 0;
    double x,y;
    while(scanf("%lf,%lf",&x,&y)!=EOF){
        Point[n++] = point(x,y);
    }
    double sum = 0.0;
    for(int i=1;i<n;i++) Point[i] -= Point[0];
    for(int i=1;i<n-1;i++){
        sum += cross_product(Point[i],Point[i+1]) / 2.0;
    }
    printf("%.10f\n",abs(sum));
    return 0;
}


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

const int N = 1e5 + 7;

ll p[64];
ll a[N];
bool vis[N];

void ins(ll x) {
	for (int i = 60; ~i; i--) {
		if (!vis[i]) continue;
		if (x >> i & 1) {
			if (!p[i]) {
				p[i] = x;
				break;
			}
			x ^= p[i];
		}
	}
}

int main() {
	int n;
	scanf("%d", &n);
	ll sum = 0;
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]), sum ^= a[i];
	ll res = 0;
	for (int i = 60; ~i; i--)
		if (!(sum >> i & 1)) vis[i] = 1;
	for (int i = 1; i <= n; i++)
		ins(a[i]);
	for (int i = 60; ~i; i--)
		if (vis[i] && !(res >> i & 1)) res ^= p[i];
	printf("%lld\n", res + (sum ^ res));
	return 0;
}

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

int n, m, x; 
vector<int> c(12);
int a[12][12];

int f(int d, int e, vector<int> b){
    if(*min_element(b.begin(),b.end()) >= x) return e;
    if(d >= n) return 1e9;
    vector<int> g = b;
    rep(i,m) g[i] += a[i][d];
    int e2 = e + c[d];
    return min(f(d+1, e, b),f(d+1,e2, g));
}

int main(){
    cin >> n >> m >> x;
    int ret;
    
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[j][i];
        }
    }
    vector<int> ans(m);
    ret = f(0, 0, ans);

    if(ret >= 1e9){
        put(-1);
    }else{
        put(ret);
    }
}   

Measured memory_bytes: 3640
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	ll N, K;
	cin >> N >> K;
	ll diff, temp;
	N %= K;
	while (1)
	{
		temp = N;
		N = abs(K - N);
		if (temp <= N)
		{
			cout << temp << '\n';
			break ;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define NMAX 10000
int main()
{
    int a[NMAX];
    int i = 0;

    for (i = 0; i < NMAX; i++)
    {
        scanf("%d", &a[i]);
        if (a[i] == 0)
            break;
        printf("Case %d: %d\n", i + 1, a[i]);
    }
    return 0;
}


Measured memory_bytes: 1980
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    //Your code here!
    ll n=0;
    cin>>n;
    map<ll,ll> s;
    ll p=0;
    s[0]=1;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll a;
        cin>>a;
        p+=a;
        s[p]++;
    }
    for(auto x:s){
        ans+=(x.second)*(x.second-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12800
#include <iostream>
using namespace std;
int a[1001];
int main()
{
	int n;
	cin >> n;
	int tmp = 0;
	for (int i = 1;i <= 9;i++)
	{
		for (int j = 1;j <= i;j++)
		{
			tmp++;
			a[tmp] = i * j;
		}
	}
	for (int i = 1;i <= 45;i++)
	{
		if (n == a[i])
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define mod 998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
// ll fact[1000005];
//void facto()
//{
//    ll lim =1000005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%MOD;
//    }
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modInverse(fact[b],MOD));
//    ret%=MOD;
//    ret*=modInverse(fact[a-b],MOD);
//    ret%=MOD;
//    return ret;
//}

void solve()
{
    ll n;cin>>n;double d;cin>>d;
    double a[n],b[n];
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    ll ans =0;
    for(ll i=0;i<n;i++)
    {
        if(sqrt(a[i]*a[i]+b[i]*b[i])<=d)ans++;
    }
    cout<<ans<<endl;
    
}
signed main()
{
   Need_for_speed(activated);
//
//    satisfy
//    {
//        solve();
//    }
//
   
    solve();
    
    return 0;
}
//Concentrate while implementing,,,!!!
 


Measured memory_bytes: 6916
N = int(input())
B = list(map(int, input().split()))

# A_1 <= B_1
# A_2 <= min(B_1, B_2)
# A_3 <= min(B_2, B_3)
# A_(N-1) <= min(B_(N-2), B_(N-1))
# A_N <= B_(N-1)
# ans = B_1 + min(B_1, B_2) + ... + min(B__(N-2), B_(N-1)) + B_(N-1)
 
ans = 0
for i in range(N):
  if i == 0: ans += B[0]
  elif i == N-1: ans += B[N-2]
  else: ans += min(B[i-1], B[i])

print(ans)

Measured memory_bytes: 9080
/**
 *      ABC 74 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 22:13:13
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, K; cin >> N >> K;
    int x[100];
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }
    int answer = 0;
    for (int i = 0; i < N; ++i) {
        answer += min(x[i], K - x[i]);
    }
    cout << answer * 2 << endl;

    return 0;
}



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

int main(void){
    long int n;
    cin >> n;
    long int ans = n;
    
    for(long int i = 1;i*i <= n;i++){
        if(n % i != 0)continue;
        long int a = (i-1)+(n/i-1);
        ans = min(ans,a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
        // 入力用変数
        int N;
        int d[50];

        // 出力用変数
        int point = 0;

        // 入力
        scanf("%d", &N);
        for (int i = 0; i < N; i++) {
                scanf("%d", &d[i]);
        }

        // 計算
        for (int i = 0; i < N-1; i++) {
                for (int j = i+1; j < N; j++) {
                        point += d[i] * d[j];
                }
        }

        // 出力
        printf("%d\n", point);

        return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] balls =  new int[N];
		int cnt = 0;
		for(int i =0; i < N ; i++ ) {
			int min = 0;
			balls[i] = sc.nextInt();
			min = 2 * Math.min(balls[i], K-balls[i]);
			cnt += min;
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 21844