akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int x;
	int ans = 0;
	cin >> x;
	int res;
	int tri;
	map<int, int> dis;
	for (int i = x; i >= 1; i--) {
		res = i;
		tri = -1;
		dis.clear();
		if (res == 1) {
			ans = 1;
			break;
		}
		for (int c = 2; c * c <= res; c++) {
			while (res % c==0) {
				dis[c]++;
				res /= c;
			}
		}
		if (res != 1) {
			dis[res]++;
		}
		tri = dis.begin()->S;
	//	clog << endl;
		repi(itr, dis) {
	//		clog << itr->F <<" "<< itr->S << endl;
			tri = __gcd(tri, itr->S); }
		if (tri != 1) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3532
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)
from itertools import permutations

def solve(N, M, a, b, c):
    MAX = 2 ** N - 1
    INF = float('inf')
    dp = [INF] * (2 ** N)
    dp[0] = 0
    for i in range(M):
        bits = 0
        for j in c[i]:
            bits += (1 << (j - 1))
        for b in range(2 ** N):
            dp[b | bits] = min(dp[b | bits], dp[b] + a[i])
    if dp[MAX] < INF:
        print(dp[MAX])
    else:
        print(-1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = []
    b = []
    c = []
    for i in range(M):
        A = int(next(tokens))  # type: int
        B = int(next(tokens))  # type: int
        a.append(A)
        b.append(B)
        c.append([ int(next(tokens)) for _ in range(B) ])
    solve(N, M, a, b, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>

using namespace std;

#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>;
const int MOD = 1e9 + 7;


int main() {
    int N;
    int a = 0;
    cin >> N;
    vi A(N);
    vi even(N);
    vi odd(N);

    rep(i, N) {
        cin >> A[i];
    }
    sort(all(A));

    rep(i, N / 2) {
        even[2 * i] = 2 * i + 1;
        even[2 * i + 1] = 2 * i + 1;
    }

    odd[0] = 0;
    rep(i, (N - 1) / 2) {
        odd[2 * i + 2] = 2 * i + 2;
        odd[2 * i + 1] = 2 * i + 2;
    }

    if (A == even) a = 1;
    if (A == odd) a = 1;
    ll ans = 0;
    if (a == 1) {
        ans = 1;
        rep(i, N / 2) {
            ans *= 2;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    char mat[n][m];
    int res[n][m];
    bool flagx=false;
    bool flagy=false;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin>>mat[i][j];
            if(mat[i][j]=='#')
            {
                if(i==0)flagx=true;
                if(j==0)flagy=true;
                res[i][j]=0;
            }
            else if(i==0&& mat[i][j]!='#'&&!flagx)
            {
                res[i][j]=1;
            }
            else if(j==0&& mat[i][j]!='#'&&!flagy)
            {
                res[i][j]=1;
            }
            else
            {
                res[i][j]=0;
            }
        }
    }
    if(res[n-1][m-1]=='#')
    {
        cout<<0<<endl;
        return 0;
    }
    long long mod=1000000007;
    for(int i=1; i<n; i++)
    {
        for(int j=1; j<m; j++)
        {
            if(mat[i][j]=='#')res[i][j]=0;
            else
            res[i][j]=(res[i-1][j]+res[i][j-1])%mod;


        }


    }
    /*for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cout<<res[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<res[n-1][m-1]<<endl;
    return 0;

}
//after competition


Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<cmath>
#include<cfloat>
#include<algorithm>
using namespace std;
#define M 200000
int main()
{
  int N;
  cin>>N;
  vector<double>a(N);
  vector< vector<double> >dp(N,vector<double>(M,DBL_MAX));
  for(int i=0;i<N;i++)cin>>a[i];
  for(int j=1;j<M;j++)dp[0][j]=fabs(a[0]-j)/a[0];
  for(int i=1;i<N;i++)for(int j=1;j<M;j++)for(int k=1;j*k<M;k++){
    dp[i][j*k]=min(dp[i][j*k],max(dp[i-1][j],fabs(a[i]-j*k)/a[i]));
  }
  double ans=DBL_MAX;
  for(int j=1;j<M;j++)ans=min(ans,dp[N-1][j]);
  printf("%.9f\n",ans);
}

Measured memory_bytes: 31000
def main():
    S = input()
    k = int(input())
    setS = set(list(S))
    count = 0
    ans = []
    for j in range(1, k + 1):
        for i in range(len(S) - j + 1):
            ans.append(S[i:i + j])
    ans = sorted(list(set(ans)))
    print(ans[k - 1])

if __name__ == '__main__':
    main()


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

//高速素因数分解(osa_k法)
const int MAX = 1e6+10;
int min_prime[MAX];

void create_min_prime(){
  for(int i=2; i<MAX; i++){
    if(min_prime[i] == 0){
      for(int j=1; j<MAX; j++){
        if(min_prime[i*j] == 0){
          min_prime[i*j] = i;
        }
        if(i*(j+1) >= MAX){
          break;
        }
      }
    }
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  
  create_min_prime();
  
  map<int,int> ans;
  for(int i=0; i<N; i++){
    set<int> S;
    while(min_prime[vec[i]] != 0){
      S.insert(min_prime[vec[i]]);
      vec[i] /= min_prime[vec[i]];
    }
    for(auto itr = S.begin(); itr != S.end(); itr++){
      ans[*itr]++;
    }
  }
  
  int coprime = 0;
  
  for(auto itr = ans.begin(); itr != ans.end(); itr++){
    coprime = max(coprime,itr->second);
  }
  
  if(coprime <= 1){
    cout << "pairwise coprime" << endl;
  }
  else if(coprime != N){
    cout << "setwise coprime" << endl;
  }
  else{
    cout << "not coprime" << endl;
  }
}



Measured memory_bytes: 14516
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string str;
  int n, i, ans=0;
  cin>>n>>str;
 
  for(i=0; i<n-2; i++){
    if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()] 

max = 0
count = 0

for i in range(n):
  if i != n-1:
    if h[i] >= h[i+1]:
      count += 1
    else:
      if max < count:
        max = count
        
      count = 0
  else:
    if max < count:
        max = count
    
      
print(max)

Measured memory_bytes: 14252
#include <iostream>

int main() {
  int a;
  int b;
  std::cin >> a >> b;
  if(a < b) {
    std::cout << "a < b" << std::endl;
  }
  else if(a > b) {
    std::cout << "a > b" << std::endl;
  }
  else if(a == b) {
    std::cout << "a == b" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3072
float x,y,v,w,x0,y0,S;
main(){
	scanf("%f,%f",&x0,&y0);
	v=x0,w=y0;
	for(;~scanf("%f,%f",&x,&y);){
		S+=(v-x)*(w+y);
		v=x,w=y;
	}
	S+=(v-x0)*(w+y0);
	printf("%f \n",S/2);
	exit(0);
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)

struct hand{
    int i, j, k;
};

vector<hand> ans;

int mat[10][10];
int n;
int mov[3][5][2] = {
    {{0,0},{-1,1},{0,0},{1,0},{1,0}} , 
    {{0,2},{0,2},{0,2},{1,0},{1,0}} , 
    {{0,0},{-1,1},{-2,2},{-1,1},{0,0}}
};
int pos[3][2] = {{1,0}, {1,1}, {2,0}};

void paint(int pi, int pj, int k, int d){
    for(int i = 0; i < 5; i++){
        for(int j = mov[k][i][0]; j <= mov[k][i][1]; j++){
            mat[pi+i][pj+j] += d;
        }
    }
}

void dfs(int pi, int pj, int cur){
    if(cur == n){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                if(mat[i][j] != 0)  return;
            }
        }
        // ok.
        for(hand t : ans)   cout << t.j << " " << t.i << " " << t.k << endl;
        exit(0);
    }

    if(mat[pi][pj] == 0){
        dfs(pi+(pj==9), (pj+1)%10, cur);
    }else{
        for(int k = 0; k < 3; k++){
            bool valid = true;
            for(int i = 0; i < 5; i++){
                for(int j = mov[k][i][0]; j <= mov[k][i][1]; j++){
                    valid &= inRange(pi+i,0,10)&&inRange(pj+j,0,10)&&(mat[pi+i][pj+j] >= 1);
                }
            }
            if(!valid)  continue;

            paint(pi, pj, k, -1);   // erase
            ans.push_back(hand({pi+pos[k][0], pj+pos[k][1], k+1}));
            dfs(pi, pj, cur+1);
            ans.pop_back();
            paint(pi, pj, k, 1); // repaint
        }
    }

}

int main(){
    cin >> n;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> mat[i][j];
        }
    }
    dfs(0,0,0);
}


Measured memory_bytes: 3184
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete


main = getInts >>= print . signum . sum



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

public static class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        long result = 0;
        for (int i = 1; i <= n; i++)
            result += i % 3 == 0 || i % 5 == 0 ? 0 : i;
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 17404
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

k, x = input_a
if k * 500 >= x
  puts "Yes"
else
  puts "No"
end

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

int main()
{
    int n;
    cin >> n;
    int t[n], a[n];
    for(int i=0; i<n; i++){
        cin >> t[i] >> a[i];
    }
    long long int ans[2]={t[0], a[0]};
    long long int tmp0, tmp1, di0, di1, mul;
    for(int i=1; i<n; i++){
        if(ans[0]%t[i]==0){
            di0=ans[0]/t[i];
            tmp0=ans[0];
        }else{
            di0=ans[0]/t[i]+1;
            tmp0=di0*ans[0];
        }

        if(ans[1]%a[i]==0){
            di1=ans[1]/a[i];
            tmp1=ans[1];
        }else{
            di1=ans[1]/a[i]+1;
            tmp1=di1*ans[1];
        }
        mul=max(di0, di1);
        ans[0]=mul*t[i];
        ans[1]=mul*a[i];
    }
    cout << ans[0]+ans[1];
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		long count = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] > B[i]) {
				count += B[i];
			} else {
				int rest = B[i] - A[i];
				count += A[i];
				if (A[i+1] > rest) {
					A[i+1] -= rest;
					count += rest;
				} else {
					count += A[i+1];
					A[i+1] = 0;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 87132
n = int(input())
clist = []
for i in range(n):
  cx, cy = list(map(int, input().split()))
  c = [cx, cy]
  clist.append(c)
dlist = []
for j in range(n):
  sc = clist[j]
  for k in range(j + 1, n):
    dc = clist[k]
    d = ((sc[0] - dc[0]) ** 2 + (sc[1] - dc[1]) ** 2) ** 0.5
    dlist.append(d)
print(sum(dlist) / n * 2)

Measured memory_bytes: 3064
// 2014/07/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int n, m, l;
	cin >> n >> m >> l;

	int A[100][100];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> A[i][j];
		}
	}

	int B[100][100];
	for(int i=0; i<m; i++){
		for(int j=0; j<l; j++){
			cin >> B[i][j];
		}
	}

	long long C[100][100];
	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			C[i][j] = 0;
		}
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			for(int k=0; k<l; k++){
				C[i][k] += A[i][j]*B[j][k];
			}
		}
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			cout << C[i][j];

			if(j==l-1){
				cout << endl;
			}
			else{
				cout << ' ';
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1312
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class _Class
{
	void _()
	{
		var S = _Ss()[0];

		int count = 0;
		char? c = null;
		for (int i = 0; i < S.Length; i++)
		{
			if (S[i] != c)
			{
				count++;
				c=S[i];	
			} 
		}

		Console.WriteLine(count-1);
	}

	static void Main(string[] args)
  {
    new _Class()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}

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

int main() {
	int a,ans;
	string b,c;
	
	cin >> a >> b >> c;
	ans=a*2;
	int i;
	int v=0;
	for(i=0;i<a;i++){
		if(b[i]==c[v]){
			ans--;
			v++;
		} 
	}	
	if(b==c){
		cout << a << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
struct Vec2D
{
    T x, y;
};

void solve()
{
    using namespace std;
    int n, k;
    cin >> n >> k;
    vec<int> v(n);

    for (auto& x : v) cin >> x;

    sort(make_reverse_iterator(v.end()), make_reverse_iterator(v.begin()));

    cout << accumulate(v.begin(), v.begin() + k, 0) << endl;

}

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		int i, j, n, q, k;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			int[] a = new int[n + 1];
			for(i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				k = sc.nextInt();
				System.out.println(Arrays.binarySearch(a, k) >= 0 ? "1" : "0");
			}
		}
	}
}


Measured memory_bytes: 107836
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;

  FOR(i, a, min(a + k, b + 1)) cout << i << endl;
  FOR(i, max(a + k, b - k + 1), b + 1) cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
vector<int>e[N];
ll ans[N];
main()
{
     int n;
     cin>>n;
     for(int i=1;i<=n-1;i++)
     {
          int u,v;
          cin>>u>>v;
          if(u>v)
            swap(u,v);
          e[u].push_back(v);
     }
     ll sum=1;
     ans[n]=1;
     for(int i=n-1;i>=1;i--)
     {
          ll now=1+ans[i+1]+(n-(i+1)+1);
          for(int u:e[i])
          {
              now-=(n-(u)+1);
          }
          ans[i]=now;
          sum+=now;
          //cout<<"i: "<<now<<endl;
     }
     cout<<sum;
}


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

int main(void)
{
    int K;
    char str1[110];
    scanf("%u",&K);
    scanf("%s",str1);
    int len=strlen(str1);
    if(len<=K)
        puts(str1);
    else
    {
        str1[K]='.';
        K++;
        str1[K]='.';
        K++;
        str1[K]='.';
        K++;
        str1[K]='\0';
        puts(str1);
    }

    return 0;
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nx = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nx[0];
        var xx = nx[1];
        var ls = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var d = 0;
        var k = 1;
        for (int i = 0; i < ls.Length; i++)
        {
            d += ls[i];
            if (d > xx)
            {
                continue;
            }

            k++;
        }
        
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <iomanip>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    string S;
    cin >> S;
    
    ll n = 0;
    ll ans = 0;
    for (ll i = 0; i < S.size(); i++) {
        if (S.at(i) == 'W') {
            ans += i - n;
            n++;
        }
    }
    
    cout << ans << endl;
}

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

int main() {
  int64_t a, b, x;
  cin >> a >> b >> x;
  int64_t a1 = a/x;
  int64_t b1 = b/x;
  if (a%x==0)
    cout << b1-a1+1 << endl;
  else
    cout << b1-a1 << endl;
}

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

#include <iostream>

#include <vector>

#include <algorithm>

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

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

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

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

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

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

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



using namespace std;



typedef long long int lli;

typedef pair<lli, lli> ii;

typedef vector<int> vi;

typedef vector<ii> vii;



int main(){

    fastio;

	int A[505];
	int n; cin>>n;
	rep(i,1,n+1) cin>>A[i];
	bool chi=1;
	int swaps=0;
	rep(i,1,n+1){
		if(A[i]!=i){
			if(A[A[i]]!=i){
				chi=false; break;
			}else{
				swaps++;
				swap(A[i], A[A[i]]);
			}
		}
		if(swaps>1){
			chi=false;
			break;
		}
	}
	if(!chi) cout<<"NO";
	else cout<<"YES";
	cout<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
#define pb push_back

typedef long long ll;
using namespace std;
int MOD = 1000000007;
int N, x, min_rank = 0;
ll ans = 1;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  FOR(i, 0, N - 1){
    cin >> x;
    if(min_rank < (i * 2 - x + 2) / 2){
      ans = ans * (i + 1 - min_rank) % MOD;
      min_rank++;
    }
  }
  FOR(i, min_rank, N){
    ans = ans * (N - i) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
long long n,k;
int main()
{
    cin>>n>>k;
    if(n*2<=k) cout<<n;
    else if(n%k==0) cout<<0;
    else cout<<min(abs(n-n/k*k),abs(n-n/k*k-k));
    return 0;
}

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

int main()
{
    string s, p;
    cin >> s >> p;

    s += s;
    if (s.find(p) != -1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

const int MAX_N = 1e5;

int s[MAX_N], n;

bool nibutan(int t) {
    int left = -1, right = n;
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (s[mid] < t) left = mid;
        else right = mid;
    }
    if (s[right] == t) return true;
    return false;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    int q;
    cin >> q;
    int cnt = 0;
    for (int i = 0, t; i < q; i++) {
        cin >> t;
        if (nibutan(t)) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3392
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;

const int MAX_V = 100;
vector<int> G[MAX_V];

int V, E;
bool seen[MAX_V];

int dfs(int s) {
    seen[s] = true;
    int see_c = 0;
    rep(i, V) if (seen[i]) see_c++;
    int ret = 0;
    if (see_c == V) ret += 1;

    rep(i, G[s].size()) {
        if (!seen[G[s][i]]) {
            ret += dfs(G[s][i]);
        }
    }
    seen[s] = false;
    return ret;
}

void solve() {
    cout << dfs(0) << endl;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        scanf("%d %d", &V, &E);
        for (int i = 0; i < E; ++i) {
            int s, t;
            scanf("%d %d", &s, &t);
            s--, t--;
            G[s].push_back(t);
            G[t].push_back(s);
        }

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>

#define ll long long
#define VL vector<ll>
#define VI vector<int>
#define FOR(i,b) for(int i= 0; i<((int)b); ++i)
#define FOR_(i,a,b) for(int i= a; i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define COUT(x) cout << x << endl;
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define EPS 1e-14
#define DIM2(R,C,arr) vector<vector<int>> arr(R);FOR(i,R) (arr)[i].resize(C);
#define DIM2INIT(R,C,arr) FOR(i,R)FOR(j,C)arr[i][j]=0;
#define MAPGEN(R,C,visited,map) char map[R][C]; FOR(i,R){string s;cin>>s;FOR(j,C){visited[i][j]=0;map[i][j]=s[j];}}
#define Point pair<int,int>
#define POINT(x,y,arr) arr[y][x]
#define SORT(a)  sort(a.begin(),a.end());
using namespace std;







int main() {
    //*** ---------------------------------------------------------------------------*//
    //
    //                            Variables and Initialize
    //
    //*----------------------------------------------------------------------------- *//
    
    ll n;
    cin >> n;
    ll i=0;
    while(true){
        if(pow(2,i) > n){
            break;
        }
        i++;
    }
    COUT(i);
    return 0;
}

Measured memory_bytes: 3280
#include <stdio.h>
 
int main(void){
 
  int A[100];
  int i,j,n,v,k;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
  for(i=0;i<n;i++){
    v = A[i];
    j = i - 1;
 
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
 
    A[j+1] = v;
 
    for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k < n-1){
    printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1860
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=110;
int n,x[N],y[N],h[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d%d",&x[i],&y[i],&h[i]);
	for(int i=0;i<101;i++)
		for(int j=0;j<101;j++)
		{
			int H;bool f=true;
			for(int k=1;k<=n;k++)
				if(h[k]!=0)
				{
					H=h[k]+abs(i-x[k])+abs(j-y[k]);
					break;
				}
			if(H<1)continue;
			for(int k=1;k<=n;k++)
			{
				int hh=max(H-abs(i-x[k])-abs(j-y[k]),0);
				if(hh!=h[k]){ f=false;break;}
			}
			if(!f)continue;
			printf("%d %d %d\n",i,j,H);return 0;
		}
}

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

int main(){
  int N; cin >> N;
  vector<int> h(N);
  for(int i = 0; i < N; i++) cin >> h[i];
  int x = 0, y = 0, ans = h[0];
  for(int i = 0; i < N - 1; i++){
    if(h[i] <= h[i + 1]){
       y++;
       ans += h[i + 1] - h[i];
    }
    else{
      x = i; y = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main () {
  int N;
  int X;
  int sum = 0;
 
  cin >> N;
  X = N;
 
  for(int i = 0; i < to_string(N).length(); i++) {
    sum += X % 10;
    X /= 10;
  }
 
  N % sum == 0 ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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[i];
    }
    int lamp = 0;
    int ans = 0;
    rep(i,N) {
        lamp = a[lamp]-1;
        ans++;
        if (lamp == 1) { break; }
        if (ans == N-1) {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#pragma GCC optimize(2)
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#define lowbit(n) n & (-n)
#define lson rt << 1
#define rson rt << 1 | 1
#define ls lson, l, mid
#define rs rson, mid + 1, r
#define clc(a, b) memset(a, b, sizeof(a))
#define Buff ios::sync_with_stdio(false)
#define rush() int Case = 0; int T; scanf("%d", &T);  while(T--)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define per(i, a, b) for(int i = a; i >= b; i --)
#define reps(i, a, b) for(int i = a; b; i ++)
#define read(a) scanf("%d", &a)
#define readd(a) scanf("%lf", &a)
#define readl(a) scanf("%lld", &a)
#define readc(a) scanf("%c", &a)
#define reads(a) scanf("%s", a)
#define sqr(x) x*x
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>PII;
const int mod = 998244353;
const double eps = 1e-6;
const int N = 2e5+7;
ll sum[N << 2], power[N << 2], pow10[N];
int color[N << 2];
void pushUP(int rt)
{
    sum[rt] = (sum[lson] + sum[rson]) % mod;
    if(color[lson] != color[rson])  color[rt] = -1;
    else                            color[rt] = color[rson];
}
void build(int rt, int l, int r)
{
    if(l == r)
    {
        color[rt] = 1;
        power[rt] = pow10[l];
        sum[rt] = power[rt];
        return ;
    }
    int mid = l + r >> 1;
    build(ls);  build(rs);
    pushUP(rt);
    power[rt] = (power[lson] + power[rson]) % mod;
}
void pushDown(int rt)
{
    if(color[rt] == -1) return ;
    color[lson] = color[rson] = color[rt];
    sum[lson] = power[lson] * 1ll * color[rt] % mod;
    sum[rson] = power[rson] * 1ll * color[rt] % mod;
    color[rt] = -1;
}
void update(int rt, int l, int r, int L, int R, int x)
{
    if(L <= l && R >= r)
    {
        sum[rt] = power[rt] * 1ll * x % mod;
        color[rt] = x;
        return ;
    }
    pushDown(rt);
    int mid = l + r >> 1;
    if(L <= mid)    update(ls, L, R, x);
    if(R > mid)     update(rs, L, R, x);
    pushUP(rt);
}
int main()
{
    int n, q;
    read(n);    read(q);
    pow10[n] = 1ll;
    per(i, n-1, 1)  pow10[i] = pow10[i+1] * 10ll % mod;
//    rep(i, 0, n)    cout << pow10[i] <<" "; puts("");
    build(1, 1, n);
    while(q --)
    {
        int l, r, x;
        read(l);    read(r);    read(x);
        update(1, 1, n, l, r, x);
        printf("%d\n", sum[1]);
    }
	return 0;
}


Measured memory_bytes: 14960
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NK = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            var answer = K == 0 ? -N : 0L;
            for (var i = 1; i <= N; i++)
            {
                var b = i;
                var a = Math.Max(b - K, 0);
                var div = N / b;
                var sub = N - b * div;
                var tmp = div * a + Math.Max(sub - K + 1, 0);
                answer += tmp;
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
n = int(input())
al = list(map(int, input().split())) 
als = sorted(al,reverse =True)

if n ==2:
    print(als[0])
    exit()

if n % 2==0:
    m = n//2
    res=sum(als[:m-1]) + sum(als[1:m])+als[m-1]

else:
    m = n//2
    res = sum(als[:m]) + sum(als[1:m+1])
    
print(res)

Measured memory_bytes: 31440
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<ArrayList<Integer>> s = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            ArrayList<Integer> list = new ArrayList<>();
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                list.add(sc.nextInt()-1);
            }
            s.add(list);
        }
        int[] p = new int[m];
        for (int i = 0; i < m; i++) p[i] = sc.nextInt();
        long ans = 0L;
        for (int i = 0; i < (1 << n); i++) {
            int[] c = new int[m];
            boolean able = true;
            for (int j = 0; j < m; j++) {
                for(int d : s.get(j)){
                    if((i >> d & 1) == 1) c[j]++;
                }
                if(c[j] % 2 != p[j]){
                    able = false;
                    break;
                }
            }
            if(able) ans++;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 25172
#include<stdio.h>
#define maxn 101111
int flag[maxn];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        flag[x]++;
        flag[y+1]--;
    }
    int ans = 0;
    int cnt = 0;
    for(int i=1;i<=n;++i)
    {
        cnt += flag[i];
        if(cnt == m)
            ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 512
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		int n = sc.nextInt();

		loop:
		for (int i = 1; i <= n; i++) {
			int x = i;

			if (x % 3 == 0) {
				sb.append(" " + i);
				continue loop;
			}

			do {
				if (x % 10 == 3) {
					sb.append(" " + i);
					continue loop;
				}
				x /= 10;
			} while (x != 0);
		}

		System.out.println(sb);
	}

}

Measured memory_bytes: 28448
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;


int main() {
  int A,B;
  cin >> A >> B;
  A--;
  B--;
  vector<vector<bool> > fld(100,vector<bool>(100,false));
  repeat(i,50){
    repeat(j,100){
      fld[i][j] = true;
    }
  }
  for(int i=0;i<50;i+=2){
    for(int j=0;j<100;j+=2){
      if(A==0){
        i=50;
        break;
      }
      fld[i][j] = false;
      A--;
    }
  }
  for(int i=99;i>=50;i-=2){
    for(int j=0;j<100;j+=2){
      if(B==0){
        i=0;
        break;
      }
      fld[i][j] = true;
      B--;
    }
  }
  cout << "100 100" << endl;
  repeat(i,100){
    repeat(j,100){
      cout << (fld[i][j]? "#":".");
    }
    cout << endl;
  }
  return 0;
}


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

const int MX = 100000;

struct UnionFind {
    vector<int> par;
    vector<int> sz;
    vector<int> tp[2];

    UnionFind(int n){
        par.resize(n);
        sz.resize(n);
        tp[0].resize(n);
        tp[1].resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
            tp[i>=MX][i]++;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        tp[0][y] += tp[0][x];
        tp[1][y] += tp[1][x];
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int N;
    cin >> N;
    UnionFind uf(2*MX);
    for(int i=0; i<N; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x, MX+y);
    }

    int64_t sum = 0;
    for(int i=0; i<2*MX; i++){
        if(uf.find(i) == i){
            sum += (int64_t) uf.tp[0][i] * uf.tp[1][i];
        }
    }

    int64_t ans = sum - N;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

constexpr ll INF       = 1000000000;/* 1e+9a */
// for(auto && i : Range(l,r))
// -> i = [l..r)
class Range {
private: struct It{ int x; int operator*(){return x;}
 bool operator!=(It& lhs){ return x<lhs.x;} void operator++(){++x;} }; It l,r;
public: Range(int n):l({0}),r({n}){} Range(int i,int n):l({i}),r({n})
 {}It& begin(){return l;} It& end(){return r;} };

void solve(istream& cin) {
    ll t;
    vector<ll> ev, od;
    for (ll i = 0; i <= (1 << 16); i++){
        ll et, ot;
        et = ot = 0;
        ll p = 1;
        for (ll j = 0; j < 16; ++j) {
            if(i & (1ll << j)){
                et += p;
                ot += p*2;
            }
            ev.push_back(et);
            od.push_back(ot);
            p *= 4;
        }
    }
    sort(ev.begin(), ev.end());
    sort(od.begin(), od.end());
    while(cin >> t){
        ll en, on;
        for (int i = 0; i < ev.size(); ++i) {
            ll search = ev[i] - t;
            auto po = lower_bound(od.begin(), od.end(), search);
            if( search == *po){
                en = ev[i];
                on = *po;
                break;
            }
        }
        cerr << "T: " << t << "ON" << on << "EN " << en << endl;
        string ans;
        bool is_en = true;
        on /= 2;
        while(en > 0 || on > 0){
            if(is_en) {
                ans.push_back('0' + (en & 1));
                en /= 4;
            }
            else{
                ans.push_back('0' + (on & 1));
                on /= 4;
            }
            is_en = !is_en;
        }
        reverse(ans.begin(), ans.end());
        if(ans.size() == 0) ans = "0";
        cout << ans << endl;

    }
}

int main(int argc, char *argv[]) {
    string FileName("C"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {    
	    cerr << sub << endl;
        string inFile = "sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}

Measured memory_bytes: 29136
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    double a,b,C;
    cin >>a >>b >>C;
    double PI = acos(-1);
    printf("%lf\n", a*b*sin(C*PI/180)/2);
    double L,c;
    c = sqrt(b*b + a*a - 2*a*b*cos(C*PI/180));
    L = a + b + c;
    printf("%lf\n",L);
    printf("%lf\n",(a*b*sin(C*PI/180)/a));
    return 0;
    
}



Measured memory_bytes: 3352
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}


static void ABC106D_AtCoderExpress2();

#if 1
int main()
{
	ABC106D_AtCoderExpress2();
	fflush(stdout);
	return 0;
}
#endif

static void ABC106D_AtCoderExpress2()
{
	int N, M, Q;
	get3int(N, M, Q);

	auto pqStat = new int[N][501];
	memset(pqStat, 0, sizeof(int) * N * 501);
	for (int i = 0; i < M; i++) {
		int l, r;
		get2int(l, r); l--; r--;
		pqStat[l][r]++;
	}

	auto pqSum = new int[N][501];
	memset(pqSum, 0, sizeof(int) * N * 501);
#if 0
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int l = i; l <= j; l++) {
				for (int r = l; r <= j; r++) {
					pqSum[i][j] += pqStat[l][r];
				}
			}
		}
	}
#else
	pqSum[0][0] = pqStat[0][0];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			pqSum[i][j + 1] += pqStat[i][j + 1] + pqSum[i][j];
		}
	}
#endif
	auto ans = new int[Q];
	for (int i = 0; i < Q; i++) {
		int p, q;
		get2int(p, q); p--; q--;

		int value = 0;
		for (int j = p; j <= q; j++) {
			value += pqSum[j][q];
			if (p > 0) {
				value -= pqSum[j][p - 1];
			}
		}
		ans[i] = value;
	}

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

	delete[] ans;
	delete[] pqStat;
	delete[] pqSum;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main()
{int n,a[100],sum=0,j,t,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
sum=sum+a[i];
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
if(a[i]>a[j]) t=a[i],a[i]=a[j],a[j]=t; 
  for(i=0;i<n;i++)
     {  
	    if(a[i]%10==0) continue;
        if(sum%10==0) sum=sum-a[i];
        else break;
     }
  if(sum%10==0) printf("%d\n",0);
  else printf("%d\n",sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n){
        if(a[i]%2==1){
            Cout("first");
            return 0;
        }
    }
    Cout("second");
    return 0;
}


Measured memory_bytes: 1024
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

h,w=map(int,input().split())
s=[input() for i in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]

whitecnt=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            whitecnt+=1
grid=[[0]*w for i in range(h)]
grid[0][0]=1
q=deque([[0,0,1]])

if s[0][0]=="#" or s[-1][-1]=="#":
    print(-1)
    exit()

while q:
    x,y,dist=q.popleft()
    for xd, yd in d:
        if 0<=x+xd<w and 0<=y+yd<h and grid[y+yd][x+xd]==0 and s[y+yd][x+xd]==".":
            if x+xd==w-1 and y+yd==h-1:
                print(whitecnt-(dist+1))
                exit()

            grid[y+yd][x+xd]=1
            q.append([x+xd,y+yd,dist+1])

print(-1)

Measured memory_bytes: 66412