akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))

gray = 0
blown = 0
green = 0
light_blue = 0
blue = 0
yellow = 0
orange = 0
red = 0
constant = 0
variable = 0

for i in a:
    if i < 400 and gray == 0:
        gray = 1
        constant += 1
    elif 400 <= i < 800 and blown == 0:
        blown = 1
        constant += 1
    elif 800 <= i < 1200 and green == 0:
        green = 1
        constant += 1
    elif 1200 <= i < 1600 and light_blue == 0:
        light_blue = 1
        constant += 1
    elif 1600 <= i < 2000 and blue == 0:
        blue = 1
        constant += 1
    elif 2000 <= i < 2400 and yellow == 0:
        yellow = 1
        constant += 1
    elif 2400 <= i < 2800 and orange == 0:
        orange = 1
        constant += 1
    elif 2800 <= i < 3200 and red == 0:
        red = 1
        constant += 1
    elif i >= 3200:
        variable += 1

if constant == 0:
    print(1, variable)
else:
    print(constant, constant+variable)


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

using namespace std;
typedef long long int ll;

ll MOD = 1000000007;

int main(){

    ll N, M; cin >> N >> M;

    ll ans = 1;

    for(ll i = N; i > 0; i--){
        ans *= i;
        ans %= MOD;
    }
    for(ll i = M; i > 0; i--){
        ans *= i;
        ans %= MOD;
    }

    if(N == M){
        ans *= 2;
        ans %= MOD;
        cout << ans << endl;
    }else if(N + 1 == M || N == M + 1){
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }

}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#define M 2400042
#define N 200001
using namespace std;
char G[M],*g=G;
inline int read()
{
	int x=0;bool w=false;
	while(*g<48||57<*g)if(*g++=='-')w=true;
	while(47<*g&&*g<58)x=(x<<1)+(x<<3)+(*g++^48);
	return w?-x:x;
}
int a[N],b[N],i,l,m,n,r;
inline bool check(int o)
{
	for(i=1;i<n;i++)
	if((a[n-i]>o)==(a[n-i+1]>o))return a[n-i]>o;
	else if((a[n+i]>o)==(a[n+i-1]>o))return a[n+i]>o;
	return n&1?a[n]>o:a[n]<=o;
}
int main()
{
	fread(G,1,M,stdin),n=read(),m=n<<1;
	for(i=1;i<m;i++)a[i]=b[i]=read();
	sort(b+1,b+m),l=1,r=m-1;
	while(l<r)check(b[l+r>>1])?l=l+r+2>>1:r=l+r>>1;
	printf("%d\n",b[l]); 
	return 0;
}

Measured memory_bytes: 4412
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  string s;
  cin >> s;
  int ans = (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]);
  puts(ans ? "Bad" : "Good");
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	k := getInt()

	fmt.Println(k * pow(k-1, n-1))
}

func pow(n, x int) int {
	m := float64(n)
	y := float64(x)
	return int(math.Pow(m, y))
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  n <- readLn :: IO Int
  ps <- map read . words <$> getLine :: IO [Int]
  print $ solve n ps

solve n ps = length . filter f $ zip3 ps (tail ps) (tail . tail $ ps)
  where
    f (x, y, z) = y /= mn && y /= mx
      where
        mn = minimum [x,y,z]
        mx = maximum [x,y,z]


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vec ans(2e5+10),dp(2e5+10),a(2e5+10);
ll n;
vector<set<ll>> G(2e5+10);

void dfs(ll f, ll ff,ll R) {
  ll l=0,r=R;
  while(r-l>1) {
    ll m=(r+l)/2;
    if(dp[m]<a[f]) l=m;
    else r=m;
  }
  ll pre=dp[r];
  dp[r]=a[f];
  if(r==R) ans[f]=R++;
  else ans[f]=R-1;
  for(ll t:G[f]) if(t!=ff) dfs(t,f,R);
  dp[r]=pre;
}

int main() {
  cin >> n;
  for(ll i=0;i<n;i++) cin >> a[i];
  for(ll i=0;i<n-1;i++) {
    ll u,v;
    cin >> u >> v;
    u--,v--;
    G[u].insert(v);
    G[v].insert(u);
  }
  for(ll i=1;i<=n;i++) dp[i]=inf;
  dfs(0,-1,1);
  for(ll i=0;i<n;i++) cout << ans[i] << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  int X = 100 * A, Y = 0;

  vector<int> vs[2];

  rep(a, F + 1) rep(b, F + 1) {
    int x = 100 * A * a + 100 * B * b;
    if (x > F) continue;
    vs[0].push_back(x);
  }

  rep(c, F + 1) rep(d, F + 1) {
    int y = C * c + D * d;
    if (y > F) continue;
    vs[1].push_back(y);
  }

  for (auto x: vs[0]) {
    for (auto y: vs[1]) {
      if (x + y > F) continue;
      if (y * (100 + E) <= E * (x + y)) {
        if (Y * (x + y) < y * (X + Y)) {
          X = x, Y = y;
        }
      }
    }
  }

  cout << (X + Y) << " " << Y << endl;
  
  return 0;
}

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

int n;
pair<int,int> v[25];

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

    cin >> n;
    for(int i=1;i<=n;i++)cin >> v[i].first;
    for(int i=1;i<=n;i++)cin >> v[i].second;

    int ans = 0;
    for(int i=1;i<=n;i++){
        if(v[i].first > v[i].second )ans += v[i].first - v[i].second;
    }
    cout << ans << "\n";




    return 0;
}


Measured memory_bytes: 256
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.StringTokenizer;

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

    static class Task {
    	long A, B, C, D, CD;
    	
    	long cnt(long x) {
    		long X = A/x*x;
    		long Y = B/x*x;
    		
    		long ret = (Y - X)/x;
    		if (A % x == 0) ret++;
    		
    		return ret;
    	}
    	
        void solve(InputReader in, PrintWriter out) {
        	A = in.nextLong();
        	B = in.nextLong();
        	C = in.nextLong();
        	D = in.nextLong();
        	CD = lcm(C, D);
        	
        	out.println((B - A + 1) - (cnt(C) + cnt(D) - cnt(CD)));
        }
        
        long gcd(long a, long b) {
    		return (a < b) ? gcd(b, a) : (b > 0) ? gcd(b, a % b) : a;
    	}
    	
    	long lcm(long a, long b) {
    		return a / gcd(a, b) * b;
    	}
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

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

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N, K;
  cin >> N >> K;
  N = N - N / K * K;
  cout << min(N, K - N) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

char s[1010];

int main()
{
	cin >> s;
	int flagN = 0, flagS = 0, flagW = 0, flagE = 0;
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == 'N')flagN = 1;
		else if (s[i] == 'S')flagS = 1;
		else if (s[i] == 'E')flagE = 1;
		else if (s[i] == 'W')flagW = 1;
	}
	if (flagN == flagS && flagW == flagE)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
require 'prime'

MAX_R = 100000

as = Array.new(MAX_R+1, 0)

1.upto(MAX_R + 1) do |i|
  as[i] = as[i-1] + ((Prime.prime?(i) && Prime.prime?((i + 1) / 2)) ? 1 : 0)
end

Q = gets.chomp.to_i

Q.times do
  l, r = gets.chomp.split.map(&:to_i)

  puts (as[r] - as[l-1])
end


Measured memory_bytes: 3452
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextInt();
		double b = sc.nextInt();
		double x = sc.nextInt();
		double menseki = Math.pow(a, 2)*b;
		double kakudo;
		double yuyo;
		double waterLevel = x/(Math.pow(a, 2));


		if(2*x > menseki){
			yuyo = b - waterLevel;
			kakudo = Math.atan(yuyo/(a/2));
			kakudo = kakudo*180.0/Math.PI;
		}else{
			kakudo = Math.atan(b/(2*x/(a*b)));
			kakudo = kakudo*180.0/Math.PI;
		}
		System.out.println(kakudo);

		sc.close();
	}
};

Measured memory_bytes: 23892
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()
    n = len(S)+1
    left=[0]*n
    right=[0]*n
    for i,s in enumerate(S):
        if s=='<':
            left[i+1]=left[i]+1
    for i,s in enumerate(S[::-1]):
        if s=='>':
            right[n-i-2]=right[n-i-1]+1
    ret =0
    for i in range(n):
        ret+= max(left[i],right[i])
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27684
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	int l = 0;
	int r = 0;
	REP(i, n - 1) if (s[i + 1] == 'E') r++;
	int m = r;
	REP(i, n-1) {
		if (s[i+1] == 'E') r--;
		if (s[i] == 'W') l++;

		m = m < (r + l) ? m : (r + l);
	}
	cout << m << endl;
	return 0;
}



Measured memory_bytes: 900
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 ll k, a, b;
 int main(){
 cin >> a >> b >> k;
if(a + b < k){
    cout << 0 << ' ' << 0;
return 0;
}
 if(a - k >= 0){
    cout << a - k << ' ' << b;
 return 0;
 } else {
 cout << '0' << ' ' << b - k + a;
 }

 return 0;

 }


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0

#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main() {

    int N;
    cin >> N;
    vector<int> dp(N, 0), h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; ++i) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
s=[input() for _ in range(3)]
st=0
f=True
while f:
    if len(s[st])==0:
        if st==0:
            print("A")
        elif st==1:
            print("B")
        else:
            print("C")
        exit()   
    else:
        pp=s[st]
        p=pp[:1]
        if len(pp)>1:
            p=pp[:1]
            s[st]=pp[1:]
        else:
            s[st]=""
        if p=="a":
            st=0
        if p=="b":
            st=1
        if p=="c":
            st=2


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std; 
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pii pair<int ,int > 
#define pb push_back
#define mo 1000000007
 ll a[100005];vector<pair<int,int> > v; 
int main()
{
	ios ; 
int n , m ; cin>>n>>m ; 
for(int i =0; i<n; i++)
cin>>a[i]; 

int b , c; 
for(int i =0 ; i<m ;i++)
{
	cin>>b>>c; 
	v.pb(mp(-c,b));
}
sort(a,a+n); sort(v.begin(),v.end());
int ind = 0; 
for(int i= 0; i<m ; i++)
{
	c = -v[i].fi ; b = v[i].se; 
	for(int j = 0;j<b ; j++)
	{
		if(ind>=n||a[ind]>=c)
		{
			i =m ; 
			break ; 
		}
		a[ind]=c; 
		ind++; 
		
	}
}

ll ans = 0; 
for(int i =0; i<n; i++)
ans+=a[i];
cout<<ans; 
	return(0);
	
}

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

namespace ABC165
{
    class D
    {
        static void Main(string[] args)
        {
            //var X = long.Parse(Console.ReadLine());
            var ABN = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var A = ABN[0]; var B = ABN[1]; var N = ABN[2];

            double x = 0;
            if (B <= N) x = B - 1;
            else x = N;
            Console.WriteLine(Math.Truncate(A * x / B));
        }
    }
}


Measured memory_bytes: 28336
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  string s; cin >> s;
  REP(i, s.length()){
    if((i+1)%2 == 1 && s[i] != 'L') continue;
    if((i+1)%2 == 0 && s[i] != 'R')  continue;
    cout << "No"  << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter

def main():
    N = II()
    A = LI()
    idxs = [0] * (N + 1)
    for i, a in enumerate(A):
        idxs[a] = i
    ll = list(range(N + 1))
    rr = list(range(N + 1))
    ans = 0
    for a in range(N, 0, -1):
        idx = idxs[a]
        l, r = ll[idx], rr[idx]
        ans += (idx - l + 1) * (r - idx + 1) * a
        ll[r + 1] = l
        rr[l - 1] = r

    return ans

print(main())

Measured memory_bytes: 35064
n = int(input())
(*a, ) = map(int, input().split())
q = int(input())
(*m, ) = map(int, input().split())
s = set()
for j in range(2 << n):
    c = 0
    for k in range(n):
        if j >> k & 1:
            c += a[k]
    s.add(c)

for i in m:
    print("yneos"[i not in s::2])


Measured memory_bytes: 5648
#include<iostream>

using namespace std;

int main(void) {
	char a, b;

	cin >> a >> b;

	if (a == 'H') {
		cout << b << endl;
	}
	else {
		if (b == 'H') {
			cout << 'D' << endl;
		}
		else {
			cout << 'H' << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,l;cin>>n>>l;
  vector<string>s(n);
  rep(i,n)cin>>s[i];
  sort(all(s));
  rep(i,n)cout<<s[i];
  cout<<endl;
  
  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*a + 2*b;
        System.out.println(area + " " + length);
        sc.close();
    }    
}


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

const int N = 40000 + 7;

int a[N], b[N];



int32_t main() {
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b; cin >> a >> b;
    for(int i = 1; i <= 1000000; i++) {
        if((i * 8) / 100 == a && (i * 10) / 100 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
    int a,b,c,d,i,k;
    scanf("%d",&k);
    for(i=0;i<k;i++){
        scanf("%d%d%d",&a,&b,&c);
        if(a>b&&a>c){
            d=c;
            c=a;
            a=d;
        }
        else if(b>a&&b>c){
            d=c;
            c=b;
            b=d;
        }
        if(a*a+b*b==c*c){
            printf("YES\n");
        }
        else if(a*a+b*b!=c*c){
            printf("NO\n");
        }
    }
return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    static void solve(Scanner in) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int[] can = { a, b, c };

        Arrays.sort(can);
        int max = can[2];
        int sum = can[0] + can[1];
        if (max == sum) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

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

const int MAXN = 1e5 + 5;
const ll INF = 1e18;

int N, M;
int u[MAXN], v[MAXN], s[MAXN];
vector <pii> E[MAXN];
ll sum[MAXN];
int coef[MAXN];

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d%d%d", u + i, v + i, s + i);
		E[u[i]].push_back({v[i], s[i]});
		E[v[i]].push_back({u[i], s[i]});
	}
}

void bye() {
	puts("0");
	exit(0);
}

void dfs(int x) {
	for (auto it : E[x])
		if (!coef[it.first]) {
			coef[it.first] = -coef[x];
			sum[it.first] = (ll)it.second - sum[x];
			dfs(it.first);
		}
}

void solve() {
	coef[1] = 1;
	dfs(1);
	
	ll lo = -INF, hi = INF;
	for (int i = 1; i <= N; i++)
		if (coef[i] == 1)
			lo = max(lo, -sum[i] + 1);
		else 
			hi = min(hi, sum[i] - 1);
	
	set <ll> vals;
	for (int i = 0; i < M; i++)
		if (coef[u[i]] == coef[v[i]]) {
			ll tmp = (ll)s[i] - sum[u[i]] - sum[v[i]];
			if (tmp % 2)
				bye();
			vals.insert(tmp / 2 * coef[u[i]]);
		}
		else if (sum[u[i]] + sum[v[i]] != (ll)s[i])
			bye();
	
	if (vals.empty())
		printf("%lld\n", max(hi - lo + 1, 0ll));
	else if (vals.size() > 1)
		bye();
	else
		printf("%d\n", *vals.begin() >= lo && *vals.begin() <= hi);
}

int main() {
	load();
	solve();
	return 0;
}

Measured memory_bytes: 11136
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int a[200010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];

  deque<int> q;
  REP(i, n) {
    if(i % 2 == 0) q.PB(a[i]);
    else q.push_front(a[i]);
  }

  if(n%2) {
    for(int i=q.size()-1; i>=0; --i) {
      cout << q[i];
      if(i != 0) cout << " ";
    }
    cout << endl;
  } else {
    REP(i, q.size()) {
      cout << q[i];
      if(i != q.size()) cout << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3840
import * as fs from 'fs'
import {type} from "os";

const input: string = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const n = parseInt(args[0][0]);

const sum = [...Array(n)]
  .map((_, i) => i + 1)
  .map(x => getFizzBuzz(x))
  .map(x => isNumber(x) ? x : 0)
  .reduce((x, y) => x + y);

console.log(sum);


function getFizzBuzz(n: number): string | number {
  const f = n % 3 === 0;
  const b = n % 5 === 0;
  if (f && b) {
    return 'FizzBuzz'
  } else if (f) {
    return 'Fizz'
  } else if (b) {
    return 'Buzz'
  } else {
    return n
  }
}

function isNumber(arg: any): arg is number {
  return typeof arg === 'number'
}


Measured memory_bytes: 83936
/*CODE BY VIJAY MUKHIJA*/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define SMOD 998244353
#define what_is(x) cout << #x << " is " << x << endl
#define what_are(x,y) cout<< #x <<" is " << x << " "<< #y <<" is " << y <<endl
using namespace std;

lli Powerm(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m; lli t=Powerm(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
lli Power(lli a,lli b){ if(b==0) return 1; if(b==1) return a; lli t=Power(a,b/2); t=(t*t); if(b&1)t=(t*a); return t;}
lli Gcd(lli a,lli b) { if(b==0) { return a; } else { return Gcd(b,a%b); } }
lli LeftMostSetBit(lli n){ if (n == 0){return 0; } lli msb = 0; while (n != 0) {n = n / 2; msb++; } return msb; }
lli RightMostSetBit(lli n){ return __builtin_ffsl(n); }
lli LLsqrt(lli x){ if(x==0 || x==1) return x; lli start=1, end=x/2, ans; while(start<=end) { lli mid=(start+end)/2; if(mid*mid==x) return mid;
else if(mid <= x/mid) ans=mid,start=mid+1; else end=mid-1; }  return ans; }
void input()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main()
{
    input();
    lli n;
    cin>>n;
    vector<lli>div(n+1,0);
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i){
                div[j]++;
        }
    }
    lli ans=0;
    for(int i=1;i<=n;i++){
            ans+=i*div[i];
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 81320
#include <bits/stdc++.h>
 
using namespace std;
 
int INF = 1e9 + 5;
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;
    map<int, int> even, odd;
    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        if (i % 2 == 0) {
            even[num]++;
        }
        else {
            odd[num]++;
        }
    }
    int e = -1, e2 = -1, o = -1, o2 = -1;
    for (auto i : even) {
        if (i.second >= even[e]) {
            e2 = e;
            e = i.first;
        }
        else if (i.second >= even[e2]) {
            e2 = i.first;
        }
    }
    for (auto i : odd) {
        if (i.second >= odd[o]) {
            o2 = o;
            o = i.first;
        }
        else if (i.second >= odd[o2]) {
            o2 = i.first;
        }
    }
    if (e != o) {
        cout << n - even[e] - odd[o] << endl;
    }
    else {
        cout << min(n-even[e]-odd[o2], n-even[e2]-odd[o]) << endl;
    }
}

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

int main() {
  long long N;
    cin >> N;
  
  vector<long long> k(N);
  for(int i = 0;i < N; i++){
    cin >> k.at(i);
}
  long long ans = k.at(0);
  bool t = true;
  sort(k.begin(), k.end());

  for(int i = 1;i < N; i++){
    if(k.at(i) <= 1000000000000000000/ans){
      ans *= k.at(i);
    } else {
      t = false;
      break;}
  }
  if(k.at(0) == 0){cout << "0" << endl;}
  else if(t){cout << ans << endl;}
  else {cout << "-1" << endl;}
}
      
    
    


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

#define ENGZ ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define sfi(x) scanf("%d" , &x)
#define sfi2(x, y) scanf("%d%d" , &x,&y)
#define sfl2(x, y) scanf("%I64d%I64d" , &x,&y)
#define sfl(x) scanf("%I64d" , &x)
#define sfl3(x, y, z) scanf("%I64d%I64d%I64d", &x, &y, &z)
#define sfd(x) scanf("%lf", &x)
#define sfd2(x, y) scanf("%lf", &x, &y)
#define sfs(x) scanf("%s", &x)
#define testv(x) cerr << x << ' '
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define test cerr << "here"
#define fst(x) cout << fixed << setprecision(x)
#define mod 1000000007
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;

ll solve(ll x)
{
    int ans = 0;
    while (x)
        ans++, x /= 10;
    return ans;
}

int main()
{
    ENGZ
    ll n, ans = 1e9;
    vector<ll> v;
    cin >> n;
    for (ll i = 1; i * i <= n; i++)
        if (n % i == 0)
            v.push_back(i), v.push_back(n / i);
    for (int i = 0; i < v.size(); i += 2)
    {
        ans = min(ans, max(solve(v[i]), solve(v[i + 1])));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, m;
    cin >> n >> m;
    vector<int> ans(n, 0);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        ans[a - 1]++;
        ans[b - 1]++;
    }
    rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 1e5 + 123;
const int PLS = 3e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e16;


ll n, a[N], b[N], w, dp[110][N];


int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> w;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= w; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= a[i])
                dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i]] + b[i]);
        }
    cout << dp[n][w];
}

Measured memory_bytes: 79360
a,b,k = gets.chomp.split.map(&:to_i)

if a >= k
    a = a - k
elsif b >= (k - a)
    b = b - (k - a)
    a = 0
else
    b = 0
    a = 0
end

puts(a.to_s + ' ' + b.to_s)


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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

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

bool chkmin(int &x,int y){return x>y?x=y,1:0;}
bool chkmax(int &x,int y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,k,tot;
int v[4005],nxt[4005],h[2005],dep[2005],siz[2005];

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot;
}

void dfs(int u,int fa){
	if((k&1)&&dep[u]==k/2+1) siz[u]=1;
	else siz[u]=0;
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa) continue;
		dep[v[p]]=dep[u]+1;
		dfs(v[p],u);
		siz[u]+=siz[v[p]];
	}
}

int main(){
	n=readint(); k=readint();
	for(int i=1;i<=n-1;i++) addedge(readint(),readint());
	int ans=1<<30;
	for(int i=1;i<=n;i++){
		dep[i]=0; dfs(i,-1);
		int now=0,tmp=0;
		for(int j=1;j<=n;j++) if(dep[j]>k/2) now++;
		if(k&1) for(int p=h[i];p;p=nxt[p]) chkmax(tmp,siz[v[p]]);
		chkmin(ans,now-tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[]a = new int[n];
        int[]b = new int[n];
        int[]c = new int[n];

        for (int i = 0; i <n ; i++) {
            a[i] = sc.nextInt()-1;

        }
        for (int i = 0; i <n ; i++) {
            b[i] = sc.nextInt();

        }
        for (int i = 0; i <n-1 ; i++) {
            c[i] = sc.nextInt();

        }
        int res = b[a[0]];
        for(int i = 1;i<n;i++) {
            res += (b[a[i]]);
        if(a[i] - a[i-1] == 1)
            res+=c[a[i-1]];

        }
        System.out.println(res);


    }

}


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

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

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

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

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll H, W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    ll cnt = 0;
    REP(i, H){
    	REP(j, W){
    		if(S[i][j]=='#') cnt++;
    	}
    }
    cout << (cnt==(H+W-1)?"Possible":"Impossible") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    ll N; cin >> N;
    cout << N*(N+1)/2-N << endl;  
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from collections import deque
# people on a line
n, m = map(int, input().split())

graph = {i: {} for i in range(1, n + 1)}


for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a][b] = c
    graph[b][a] = -c



distance = ["inf" for i in range(n + 1)]

# グラフにおいて順に点を決めてって、矛盾がないかどうかを調べる
visited = [False for i in range(n + 1)]
visited[0] = True


def find(x):
    d = deque()
    visited[x] = True
    distance[x] = 0
    d.append(x)
    flag = True
    while d and flag:

        x = d.popleft()
        for node in graph[x]:
            if visited[node] == False:
                visited[node] = True
                d.append(node)
                if distance[node] == "inf":
                    distance[node] = distance[x] + graph[x][node]
                else:
                    if  distance[node] != distance[x] + graph[x][node]:
                        flag = False
                        break
            elif visited[node]==True:
                if distance[node]!=distance[x]+graph[x][node]:
                    flag=False
                    break
         
    if flag:
        return False
    else:
        return True

all_flag = True
not_visited = True
while not_visited and all_flag:
    judge = False
    for i in range(1, n + 1):
        if visited[i] == False:
            judge = True
            if find(i):
                all_flag = False
                break
            else:
                pass

    if not judge:
        not_visited = False

if all_flag:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 140624
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>

using namespace std;

int main() {
	int N,M,C;
	cin >> N >> M >> C;
	vector<int> a(M),b(M);
	
	for (int i = 0; i < M; i++) {
		cin >> b.at(i);
	}
	
	int tmp = 0, answer = 0;
	
	for(int i = 0; i < N; i++){
		tmp = 0;
		for (int j = 0; j < M; j++) {
			cin >> a.at(j);
			tmp = tmp + a.at(j) * b.at(j);
		}
		if (tmp+C > 0) {
			answer++;
//			cout << "dbg OK " << i << " " << tmp+C << endl;
		} else {
//			cout << "dbg NG " << i << " " << tmp+C << endl;
		}
			
	}
	cout << answer << endl;

	return 0;
}


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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int count=0;
  int count_b=0;
  for(int i=0;i<n;i++){
    if(s.at(i) == 'a' && count < a+b){
      count++;
      cout << "Yes" <<endl;
    }
    else if (s.at(i) == 'b' && count < a+b && count_b < b){
      count++;
      count_b++;
      cout << "Yes" << endl;
    }
    else
      cout << "No" << endl;
  }      
}


Measured memory_bytes: 3736
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_B
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
int main(){

  int a, b;
  double theta;
  cin >> a >> b >> theta;
  theta = M_PI*theta/180;

  double S = a * b * sin(theta)/2;

  double c = sqrt(a*a + b*b - 2*a*b*cos(theta));
  double L = a + b + c;
  double h = S*2/a;
  printf("%.8lf \n", S);
  printf("%.8lf \n", L);
  printf("%.8lf \n", h);
}

Measured memory_bytes: 1248
#include<stdio.h>
int main()
{
    int n,t;
    int a[109];
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    int s1,s2,x,MAX=100000;
    for(int i=1; i<n; i++)
    {
        s1=0;
        s2=0;
        for(int j=i; j>=1; j--)
        {
            s1+=a[j];
        }
        for(int h=i+1; h<=n; h++)
        {
            s2+=a[h];
        }
        if(s2>=s1)
        {
            t=s2;
            s2=s1;
            s1=t;
        }
        x=s1-s2;
        if(x<=MAX)
        {
            MAX=x;
        }
    }
    printf("%d\n",MAX);
    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    val hoge = (1..b).map { a }.joinToString("").toInt()
    val fuga = (1..a).map { b }.joinToString("").toInt()
    println(if(hoge <= fuga) fuga else hoge)
}

Measured memory_bytes: 38120
#include <stdio.h>

int main(void){
  int n,s=0,i,x;
  scanf("%d",&n);
  for(i=1;i<=n;++i){
    scanf("%d",&x);
    if(x!=i) s++;
  }
  if(s==0 || s==2)  printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
 
#define N 8
 
int a[N][N] = {{}};
int row[N] = {};
int l[15] = {};
int r[15] = {};
int s[N] = {};
 
void print(void);
void backtrack(int); 
 
int main(){
 
 
  int i,j,r,c,k;
 
 
  scanf("%d",&k);
 
  for(i = 0;i < k;i++){
    scanf("%d%d",&r,&c);
    a[r][c] = 1;
  }
  backtrack(0);
}
 
void backtrack(int i){
  int j;
 
  if(i == N){
    print();
    return;
  }
 
  for(j = 0;j < N;j++){
    if(s[j] == 1 || l[i + j] == 1 || r[i - j + N - 1] == 1) continue;
 
    row[i] = j;
    l[i + j] = r[i - j + N - 1] = s[j] = 1;
 
    backtrack(i + 1);
 
    row[i] = s[j] = l[i + j] = r[i - j + N - 1] = 0;
 
  }
 
}
 
void print(){
 
  int i,j;
 
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(a[i][j] == 1){
        if(row[i] != j) {
          return;
        }
      }
    }
  }
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
 
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    ll val = A[0];
    rep(i,1,N) val ^= A[i];
    if(val == 0){
        print("Yes");
    }else{
        print("No");
    }


    
}

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

int main(){
	int N,M,A;
	cin>>N;
	int Ih[N];
	int Im[N];
	for(int i=0;i<N;i++){
		cin>>Ih[i];
		cin>>Im[i];
	}
	cin>>M;
	int Th[M];
	int Tm[M];
	for(int i=0;i<M;i++){
		cin>>Th[i];
		cin>>Tm[i];
	}
	A=N+M;
	int Ah[A];
	int Am[A];
	for(int i=0;i<N;i++){
		Ah[i]=Ih[i];
		Am[i]=Im[i];
	}
	for(int i=0;i<M;i++){
		Ah[N+i]=Th[i];
		Am[N+i]=Tm[i];
	}
	int flag=1;
	while(flag){
		flag=0;
		int tmp1,tmp2;
		for(int j=0;j<A-1;j++){
			if(Ah[j]>Ah[j+1]){
				tmp1=Ah[j];
				Ah[j]=Ah[j+1];
				Ah[j+1]=tmp1;
				tmp2=Am[j];
				Am[j]=Am[j+1];
				Am[j+1]=tmp2;
				flag=1;
			}else if(Ah[j]==Ah[j+1]){
				if(Am[j]>Am[j+1]){
					tmp1=Ah[j];
					Ah[j]=Ah[j+1];
					Ah[j+1]=tmp1;
					tmp2=Am[j];
					Am[j]=Am[j+1];
					Am[j+1]=tmp2;
					flag=1;
				}
			}
		}	
	}
	int num;
	for(int i=0;i<A;i++){
		num=1;
		if(Ah[i]==Ah[i+1]&&Am[i]==Am[i+1]){
			num=0;
		}	
		if(num){
			if(i!=A-1){
				if(Am[i]<10){
					cout<<Ah[i]<<":"<<"0"<<Am[i]<<" ";
				}else{
					cout<<Ah[i]<<":"<<Am[i]<<" ";
				}
			}else{
				if(Am[i]<10){
					cout<<Ah[i]<<":"<<"0"<<Am[i];
				}else{
					cout<<Ah[i]<<":"<<Am[i];
					}
			}
		}
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <set>
using namespace std;


int main(){
	int n;
    int cx, cy, ch;
    int min_h = 1000000001, max_h = 0;
    int x[200], y[200], h[200];
    int tmp;
    cin >> n;
	for(int i=0;i<n;i++){
        cin >> x[i] >> y[i] >> h[i];
        if(min_h > h[i]) min_h = h[i];
        if(max_h < x[i] + y[i] + h[i]) max_h = x[i] + y[i] + h[i];
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            for(int k=min_h;k<=max_h;k++){
                int flag = 0;
                for(int l=0;l<n;l++){
                    tmp = k - abs(x[l] - i) - abs(y[l] - j);
                    if(tmp < 0) tmp = 0;
                    if(tmp != h[l]){
                        flag = 1;
                        break;
                    }
                }
                if(flag == 0){
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i=0; i<N; i++){
        cin >> W[i];
    }
    int ans=10000;
    for(int T=1; T<N; T++){
     	int s1=0;
    	int s2=0;
        for(int i=0; i<T; i++){
            s1+=W[i]; 
        }
        for(int i=T; i<N; i++){
            s2+=W[i]; 
        }
        ans = min(ans, abs(s1-s2));
    }    
    cout << ans;
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A ,B ,sum , subtract , multiply ;
    cin >> A >> B ;
    sum = A + B;
    subtract = A -B;
    multiply = A * B;
    if (subtract>=sum && subtract >= multiply){
        cout << subtract << endl;
    }
    else if(sum >=subtract && sum >= multiply){
        cout << sum <<endl;
    }
    else if (multiply>=subtract && multiply >= sum){
        cout << multiply << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
n = int(sys.stdin.readline())
h = [int(i) for i in sys.stdin.readline().split()]

def cond(h):
    if len(h) == 1:
        return True
    for index in range(n - 1):
        diff = h[index + 1] - h[index]
        if diff == 0:
            continue
        if diff > 0:
            h[index + 1] -= 1
            continue
        if diff < 0:
            return False
    return True

if cond(h):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int numsplit(vector<tuple<int, int, int>>& vt, vector<int>& vpos) {
  int cntsplit=1;
  auto tmp = vt;
  sort(all(tmp), [](tuple<int, int, int>& a,tuple<int, int, int>& b){return get<0>(a) < get<0>(b);});
  int pos=vpos[0];
  for(int l=0;l<tmp.size();++l){
    cntsplit += distance(find(all(vpos), pos), find(all(vpos),get<0>(tmp[l])));
    pos = get<1>(tmp[l]);
  }
  cntsplit += distance(find(all(vpos), pos), find(all(vpos),vpos[vpos.size()-1]));
  return cntsplit;
}

int main() {
  int n,m;cin >> n>>m;
  vector<int> v(m);
  for(int i=0;i<m;++i){
    cin >> v[i];
  }
  sort(all(v));
  if(n>=m) {
    cout << 0 << endl;
    return 0;
  }
  vector<tuple<int, int, int>> vt;
  for(int j=1;j<m;++j){
    vt.push_back(make_tuple(v[j-1], v[j],v[j] - v[j-1]));
  }
  sort(all(vt), [](tuple<int, int, int>& a,tuple<int, int, int>& b){return get<2>(a) < get<2>(b);});
  //while(numsplit(vt, v) < n){
  //  vt.pop_back();
  //}
  vt.resize(vt.size() - n+1);
  int out = 0;
  for (int k=0;k<vt.size();++k) {
    out += get<2>(vt[k]);
  }
  cout << out << endl;
  return 0;
}


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

signed main() {
	string s, t;
	std::cin >> s >> t;
	int len = s.length();
	int answer = 0;
	for (int i = 0; i < len; i++)
		if (s[i] != t[i]) {
			++answer;
		}
	std::cout << answer << '\n';
}

Measured memory_bytes: 3860